Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/AzureStack/AzSdk.reference.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.props'))" />
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="[3.3.9, 4.0.0)" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="[2.3.9, 3.0.0)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
<PackageReference Include="System.Net.Http" Version="4.3.0"/>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<PackageReference Include="Newtonsoft.Json" Version="6.0.8" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/AzureStack/AzSdk.test.reference.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('test.props'))" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Test.HttpRecorder" Version="[1.8.1,2.0.0)" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework" Version="[1.7.1,2.0.0)" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="[3.3.9, 4.0.0)" />
<PackageReference Include="Microsoft.Azure.ResourceManager" Version="[1.1.0-preview]" />

<!-- This is needed for discovering tests in test explorer -->
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<PackageId>Commerce.Admin.Tests</PackageId>
<Description>Commerce.Admin.Tests Class Library</Description>
<AssemblyName>Commerce.Admin.Tests</AssemblyName>
<VersionPrefix>1.0.0-preview</VersionPrefix>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Commerce.Admin\Microsoft.AzureStack.Management.Commerce.Admin.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="SessionRecords\**\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Commerce.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Commerce.Tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("1b24bc4a-6e4d-4feb-b5d5-c9684c60a308")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"Entries": [
{
"RequestUri": "/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/subscriberUsageAggregates?api-version=2015-06-01-preview&reportedStartTime=2017-09-06T00:00:00Z&reportedEndTime=2017-09-07T00:00:00Z",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMWMwZGFhMDQtMDFhZS00ZGY5LWE1ZDgtNDkxYjc1NWY1Mjg4L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29tbWVyY2Uvc3Vic2NyaWJlclVzYWdlQWdncmVnYXRlcz9hcGktdmVyc2lvbj0yMDE1LTA2LTAxLXByZXZpZXcmcmVwb3J0ZWRTdGFydFRpbWU9MjAxNy0wOS0wNlQwMCUzQTAwJTNBMDBaJnJlcG9ydGVkRW5kVGltZT0yMDE3LTA5LTA3VDAwJTNBMDAlM0EwMFo=",
"RequestMethod": "GET",
"RequestBody": "",
"RequestHeaders": {
"x-ms-client-request-id": [
"a4a62639-68fa-4fe3-85ea-8d2eb24cad12"
],
"accept-language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.6.25211.01",
"Microsoft.AzureStack.Management.Commerce.Admin.CommerceAdminClient/0.1.0.0"
]
},
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-9764F92C-E44A-498E-8DC1-AAD66587A810\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-9764F92C-E44A-498E-8DC1-AAD66587A810\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourcegroups/derpgroup/providers/Microsoft.Storage/storageaccounts/vmefbj65\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":null,\\\"additionalInfo\\\":null}}\",\r\n \"quantity\": 0.0029740091413259506,\r\n \"meterId\": \"9764F92C-E44A-498E-8DC1-AAD66587A810\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-43DAF82B-4618-444A-B994-40C23F7CD438\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-43DAF82B-4618-444A-B994-40C23F7CD438\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourcegroups/derpgroup/providers/Microsoft.Storage/storageaccounts/vmefbj65\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":null,\\\"additionalInfo\\\":null}}\",\r\n \"quantity\": 0.051000000000000004,\r\n \"meterId\": \"43DAF82B-4618-444A-B994-40C23F7CD438\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-6dab500f-a4fd-49c4-956d-229bb9c8c793\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-6dab500f-a4fd-49c4-956d-229bb9c8c793\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourceGroups/derpgroup/providers/Microsoft.Compute/virtualMachines/simplewinvmd\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":\\\"null\\\",\\\"additionalInfo\\\":\\\"{\\\\\\\"ServiceType\\\\\\\":\\\\\\\"Standard_A1\\\\\\\",\\\\\\\"ImageType\\\\\\\":null}\\\"}}\",\r\n \"quantity\": 3.9998271341111109,\r\n \"meterId\": \"6dab500f-a4fd-49c4-956d-229bb9c8c793\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-9cd92d4c-bafd-4492-b278-bedc2de8232a\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-9cd92d4c-bafd-4492-b278-bedc2de8232a\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourceGroups/derpgroup/providers/Microsoft.Compute/virtualMachines/simplewinvmd\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":\\\"null\\\",\\\"additionalInfo\\\":\\\"{\\\\\\\"ServiceType\\\\\\\":\\\\\\\"Standard_A1\\\\\\\",\\\\\\\"ImageType\\\\\\\":null}\\\"}}\",\r\n \"quantity\": 3.9998271341111109,\r\n \"meterId\": \"9cd92d4c-bafd-4492-b278-bedc2de8232a\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-B5C15376-6C94-4FDD-B655-1A69D138ACA3\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-B5C15376-6C94-4FDD-B655-1A69D138ACA3\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourcegroups/derpgroup/providers/Microsoft.Storage/storageaccounts/vmefbj65\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":null,\\\"additionalInfo\\\":null}}\",\r\n \"quantity\": 47.745195036754012,\r\n \"meterId\": \"B5C15376-6C94-4FDD-B655-1A69D138ACA3\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-09F8879E-87E9-4305-A572-4B7BE209F857\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-09F8879E-87E9-4305-A572-4B7BE209F857\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourcegroups/derpgroup/providers/Microsoft.Storage/storageaccounts/vmefbj65\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":null,\\\"additionalInfo\\\":null}}\",\r\n \"quantity\": 6.866455078125E-05,\r\n \"meterId\": \"09F8879E-87E9-4305-A572-4B7BE209F857\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/UsageAggregate/36770ead-1c95-4048-8ff3-d727dd5007de-3023FEF4-ECA5-4D7B-87B3-CFBC061931E8\",\r\n \"name\": \"36770ead-1c95-4048-8ff3-d727dd5007de-3023FEF4-ECA5-4D7B-87B3-CFBC061931E8\",\r\n \"type\": \"Microsoft.Commerce/UsageAggregate\",\r\n \"properties\": {\r\n \"subscriptionId\": \"36770ead-1c95-4048-8ff3-d727dd5007de\",\r\n \"usageStartTime\": \"2017-09-05T17:00:00-07:00\",\r\n \"usageEndTime\": \"2017-09-06T17:00:00-07:00\",\r\n \"instanceData\": \"{\\\"Microsoft.Resources\\\":{\\\"resourceUri\\\":\\\"/subscriptions/36770ead-1c95-4048-8ff3-d727dd5007de/resourcegroups/derpgroup/providers/Microsoft.Storage/storageaccounts/vmefbj65\\\",\\\"location\\\":\\\"local\\\",\\\"tags\\\":null,\\\"additionalInfo\\\":null}}\",\r\n \"quantity\": 0.00011140573769807816,\r\n \"meterId\": \"3023FEF4-ECA5-4D7B-87B3-CFBC061931E8\"\r\n }\r\n }\r\n ],\r\n \"nextLink\": \"https://adminmanagement.local.azurestack.external/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/subscriberUsageAggregates?api-version=2015-06-01-preview&reportedStartTime=2017-09-06T00:00:00Z&reportedEndTime=2017-09-07T00:00:00Z/subscriptions/1c0daa04-01ae-4df9-a5d8-491b755f5288/providers/Microsoft.Commerce/subscriberUsageAggregates?api-version=2015-06-01-preview&reportedStartTime=2017-09-06T00%3a00%3a00Z&reportedEndTime=2017-09-07T00%3a00%3a00Z&continuationToken=L3N1YnNjcmlwdGlvbnMvMzY3NzBlYWQtMWM5NS00MDQ4LThmZjMtZDcyN2RkNTAwN2RlL3Jlc291cmNlZ3JvdXBzL2RlcnBncm91cC9wcm92aWRlcnMvTWljcm9zb2Z0LlN0b3JhZ2Uvc3RvcmFnZWFjY291bnRzL3ZtZWZiajY1LzMwMjNGRUY0LUVDQTUtNEQ3Qi04N0IzLUNGQkMwNjE5MzFFOC82MzY0MDI1MjgwMDAwMDAwMDAvNjM2NDAyNTI4MDAwMDAwMDAw\"\r\n}",
"ResponseHeaders": {
"Content-Length": [
"6545"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Expires": [
"-1"
],
"Cache-Control": [
"no-cache"
],
"Date": [
"Wed, 06 Sep 2017 22:13:35 GMT"
],
"Pragma": [
"no-cache"
],
"X-Powered-By": [
"ASP.NET"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"14761"
],
"x-ms-request-id": [
"d2a24d60-7347-4c54-bb58-1eb04c398e56"
],
"x-ms-correlation-request-id": [
"d2a24d60-7347-4c54-bb58-1eb04c398e56"
],
"x-ms-routing-request-id": [
"LOCAL:20170906T221336Z:d2a24d60-7347-4c54-bb58-1eb04c398e56"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
],
"X-Content-Type-Options": [
"nosniff"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {
"SubscriptionId": "1c0daa04-01ae-4df9-a5d8-491b755f5288"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.

using System;
using System.Net;

using Microsoft.Rest.ClientRuntime.Azure.TestFramework;

namespace Commerce.Tests
{
/// <summary>
/// Base class for all AzureStack tests. This class should not be modified but extended through a child class.
/// </summary>
///
public abstract class AzureStackTestBase<T> where T : class
{

/// <summary>
/// Reference to service client.
/// </summary>
protected T client;

/// <summary>
/// Validate the client.
/// </summary>
/// <param name="client">The instantiated client we want to validate.</param>
protected abstract void ValidateClient(T client);

/// <summary>
/// The default location for all admin actions. Override in derived class as needed.
/// </summary>
protected string Location = "local";

/// <summary>
/// Run a test that accepts no arguments. An exception can be
/// </summary>
/// <param name="test">The test we wish to run.</param>
/// <param name="before">Function to execute before your test has completed.</param>
/// <param name="after">Function to execute after your test has completed.</param>
/// <param name="status">Expected returned HttpStatusCode.</param>
/// <exception cref="System.Exception">Thrown when an unexpected exception occurs.</exception>
///
protected void RunTest(Action<T> test,
Action before = null,
Action after = null,
HttpStatusCode status = HttpStatusCode.OK,
[System.Runtime.CompilerServices.CallerMemberName]
string methodName= "testframework_failed") {

Exception caught = null;

try
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = status };
handler.IsPassThrough = true;

using (MockContext context = MockContext.Start(typeof(T).Name, methodName))
{
var client = context.GetServiceClient<T>(handlers: handler);
ValidateClient(client);

before?.Invoke();
test(client);
after?.Invoke();
}
}
catch (Exception ex)
{
caught = ex;
}
finally
{
if (caught != null)
{
throw new Exception("Test failed", caught);
}
}
}

public void IgnoreExceptions(Action action) {
try { action(); }
catch (Exception) { }
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//

using Microsoft.AzureStack.Management.Commerce.Admin;
using Xunit;

namespace Commerce.Tests
{

public class CommerceTestBase : AzureStackTestBase<CommerceAdminClient>
{
public CommerceTestBase()
{
// Empty
}

protected override void ValidateClient(CommerceAdminClient client)
{
// validate creation
Assert.NotNull(client);

// validate objects
Assert.NotNull(client.SubscriberUsageAggregates);
Assert.NotNull(client.SubscriptionId);
}
}
}
Loading