Skip to content

Commit

Permalink
code gen + enable/disable https test (Azure#2854)
Browse files Browse the repository at this point in the history
* code gen + enable/disable https test

* fix assembly version
  • Loading branch information
csmengwan authored and Hovsep committed Feb 23, 2017
1 parent 336007e commit f979c41
Show file tree
Hide file tree
Showing 27 changed files with 1,646 additions and 482 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using System.Collections.Generic;

namespace Cdn.Tests.ScenarioTests
{
public static class CdnTestExtensions
{
public static IEnumerable<T> ToIEnumerable<T>(this IEnumerator<T> enumerator)
{
while (enumerator.MoveNext())
{
yield return enumerator.Current;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Cdn.Tests.Helpers;
using Xunit;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System;

namespace Cdn.Tests.ScenarioTests
{
Expand Down Expand Up @@ -92,6 +93,11 @@ public void CustomDomainCRUDTest()
customDomains = cdnMgmtClient.CustomDomains.ListByEndpoint(resourceGroupName, profileName, endpointName);
Assert.Equal(2, customDomains.Count());

// Enable custom https on custom domain that is already enabled should fail
Assert.ThrowsAny<ErrorResponseException>(() => {
cdnMgmtClient.CustomDomains.DisableCustomHttps(resourceGroupName, profileName, endpointName, customDomainName2);
});

// Delete second custom domain on stopped endpoint should succeed
cdnMgmtClient.CustomDomains.Delete(resourceGroupName, profileName, endpointName, customDomainName2);

Expand All @@ -106,6 +112,9 @@ public void CustomDomainCRUDTest()
// Start endpoint
cdnMgmtClient.Endpoints.Start(resourceGroupName, profileName, endpointName);

// Enable custom https on custom domain that is already enabled should fail
cdnMgmtClient.CustomDomains.EnableCustomHttps(resourceGroupName, profileName, endpointName, customDomainName1);

// Delete first custom domain on stopped endpoint should succeed
cdnMgmtClient.CustomDomains.Delete(resourceGroupName, profileName, endpointName, customDomainName1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Azure.Management.Cdn.Models;

namespace Cdn.Tests.ScenarioTests
{
Expand All @@ -31,7 +32,7 @@ public void GetEdgeNodeTest()
var cdnMgmtClient = CdnTestUtilities.GetCdnManagementClient(context, handler1);
var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2);

var edgeNodes = cdnMgmtClient.EdgeNodes.List().Value;
var edgeNodes = cdnMgmtClient.EdgeNodes.List().GetEnumerator().ToIEnumerable<EdgeNode>().ToList();

Assert.Equal(0, edgeNodes.Select(e => e.Name).Except(expectedEdgeNodeNames).Count());
Assert.Equal(0, expectedEdgeNodeNames.Except(edgeNodes.Select(e => e.Name)).Count());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public void ProfileCheckUsageTest()
var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2);

// CheckUsage on subscription should return zero profiles
var subscriptionLevelUsages = cdnMgmtClient.CheckResourceUsage();
var subscriptionLevelUsages = cdnMgmtClient.ListResourceUsage();
Assert.Equal(1, subscriptionLevelUsages.Count());

var defaultUsage = subscriptionLevelUsages.First();
Expand All @@ -528,7 +528,7 @@ public void ProfileCheckUsageTest()
var profile = cdnMgmtClient.Profiles.Create(resourceGroupName, profileName, createParameters);
VerifyProfileCreated(profile, createParameters);

subscriptionLevelUsages = cdnMgmtClient.CheckResourceUsage();
subscriptionLevelUsages = cdnMgmtClient.ListResourceUsage();
Assert.Equal(1, subscriptionLevelUsages.Count());

var usageAfterCreation = subscriptionLevelUsages.First();
Expand Down
Loading

0 comments on commit f979c41

Please sign in to comment.