-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from tomhollander/master
Initial UI cleanup
- Loading branch information
Showing
97 changed files
with
88,748 additions
and
1,855 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using MIGAZ.Generator; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Collections; | ||
using System.Xml; | ||
|
||
namespace MIGAZ.Tests.Fakes | ||
{ | ||
class FakeAsmRetriever : AsmRetriever | ||
{ | ||
private Dictionary<string, string[]> _keyProperties = new Dictionary<string, string[]> | ||
{ | ||
{ "Subscriptions", new string[] { } }, | ||
{ "VirtualNetworks", new string[] { } }, | ||
{ "ClientRootCertificates", new string[] { "virtualnetworkname"} }, | ||
{ "ClientRootCertificate", new string[] { "virtualnetworkname", "thumbprint" } }, | ||
{ "NetworkSecurityGroup", new string[] { "name"} }, | ||
{ "RouteTable", new string[] { "name"} }, | ||
{ "NSGSubnet", new string[] { "virtualnetworkname", "subnetname" } }, | ||
{ "VirtualNetworkGateway", new string[] { "virtualnetworkname" } }, | ||
{ "VirtualNetworkGatewaySharedKey", new string[] { "virtualnetworkname", "localnetworksitename" } }, | ||
{ "StorageAccounts", new string[] { } }, | ||
{ "StorageAccount", new string[] { "name" } }, | ||
{ "StorageAccountKeys", new string[] { "name" } }, | ||
{ "CloudServices", new string[] { } }, | ||
{ "CloudService", new string[] { "name" } }, | ||
{ "VirtualMachine", new string[] { "cloudservicename", "deploymentname", "virtualmachinename" } }, | ||
{ "VMImages", new string[] { } }, | ||
}; | ||
private Dictionary<string, XmlNodeList> _responses = new Dictionary<string, XmlNodeList>(); | ||
|
||
public FakeAsmRetriever(ILogProvider logProvider, IStatusProvider statusProvider) : base(logProvider, statusProvider) | ||
{ | ||
} | ||
|
||
public void SetResponse(string resourceType, Hashtable info, XmlNodeList nodes) | ||
{ | ||
string key = resourceType + ":" + SerialiseHashTable(resourceType, info); | ||
_responses[key] = nodes; | ||
} | ||
|
||
public override XmlNodeList GetAzureASMResources(string resourceType, string subscriptionId, Hashtable info, string token) | ||
{ | ||
string key = resourceType + ":" + SerialiseHashTable(resourceType, info); | ||
return _responses[key]; | ||
} | ||
|
||
private string SerialiseHashTable(string resourceType, Hashtable ht) | ||
{ | ||
var sb = new StringBuilder(); | ||
|
||
// Sort keys | ||
var keyList = new List<string>(); | ||
foreach(var key in ht.Keys) | ||
{ | ||
keyList.Add((string)key); | ||
} | ||
keyList.Sort(); | ||
|
||
foreach (var key in keyList) | ||
{ | ||
if (_keyProperties[resourceType].Contains(key)) // Don't include properties from the hashtable that aren't needed | ||
{ | ||
sb.Append(key); | ||
sb.Append("="); | ||
sb.Append(ht[key]); | ||
sb.Append(";"); | ||
} | ||
} | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using MIGAZ.Generator; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MIGAZ.Tests.Fakes | ||
{ | ||
class FakeLogProvider : ILogProvider | ||
{ | ||
public void WriteLog(string function, string message) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using MIGAZ.Generator; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MIGAZ.Tests.Fakes | ||
{ | ||
class FakeStatusProvider : IStatusProvider | ||
{ | ||
public void UpdateStatus(string v) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using MIGAZ.Generator; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MIGAZ.Tests.Fakes | ||
{ | ||
class FakeTelemetryProvider : ITelemetryProvider | ||
{ | ||
public void PostTelemetryRecord(string tenantId, string subscriptionId, Dictionary<string, string> processedItems) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using MIGAZ.Generator; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MIGAZ.Tests.Fakes | ||
{ | ||
class FakeTokenProvider : ITokenProvider | ||
{ | ||
public string GetToken(string tenantId) | ||
{ | ||
return "TOKEN"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1587480D-A92D-4FCA-A892-D4E339536D38}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>MIGAZ.Tests</RootNamespace> | ||
<AssemblyName>MIGAZ.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> | ||
<IsCodedUITest>False</IsCodedUITest> | ||
<TestProjectType>UnitTest</TestProjectType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.XML" /> | ||
</ItemGroup> | ||
<Choose> | ||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'"> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | ||
</ItemGroup> | ||
</When> | ||
<Otherwise> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework"> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</Otherwise> | ||
</Choose> | ||
<ItemGroup> | ||
<Compile Include="Fakes\FakeAsmRetriever.cs" /> | ||
<Compile Include="Fakes\FakeLogProvider.cs" /> | ||
<Compile Include="Fakes\FakeStatusProvider.cs" /> | ||
<Compile Include="Fakes\FakeTelemetryProvider.cs" /> | ||
<Compile Include="Fakes\FakeTokenProvider.cs" /> | ||
<Compile Include="StorageTests.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="TestHelper.cs" /> | ||
<Compile Include="VirtualMachineTests.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\MIGAZ\MIGAZ.csproj"> | ||
<Project>{90C588A6-C9CE-41BD-81EB-703A63AEF46C}</Project> | ||
<Name>MIGAZ</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Choose> | ||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</When> | ||
</Choose> | ||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("MIGAZ.Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("MIGAZ.Tests")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("1587480d-a92d-4fca-a892-d4e339536d38")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MIGAZ.Generator; | ||
using MIGAZ.Tests.Fakes; | ||
using System.IO; | ||
using MIGAZ.Models; | ||
using System.Xml; | ||
using System.Collections; | ||
using Newtonsoft.Json.Linq; | ||
using System.Linq; | ||
|
||
namespace MIGAZ.Tests | ||
{ | ||
[TestClass] | ||
public class StorageTests | ||
{ | ||
|
||
private const string sampleAsmStorageInfo = @"<StorageService> | ||
<Url>storage-account-request-uri</Url> | ||
<ServiceName>mystorage</ServiceName> | ||
<StorageServiceProperties> | ||
<AccountType>Standard_LRS</AccountType> | ||
<Description>description</Description> | ||
<AffinityGroup>affinity-group</AffinityGroup> | ||
<Location>Antarctica</Location> | ||
<Label>base64-encoded-label</Label> | ||
<Status>status</Status> | ||
<Endpoints> | ||
<Endpoint>https://mystorage.blob.core.windows.net</Endpoint> | ||
<Endpoint>https://mystorage.queue.core.windows.net</Endpoint> | ||
<Endpoint>https://mystorage.table.core.windows.net</Endpoint> | ||
<Endpoint>https://mystorage.file.core.windows.net</Endpoint> | ||
</Endpoints> | ||
<GeoReplicationEnabled>geo-replication-indicator</GeoReplicationEnabled> | ||
<GeoPrimaryRegion>primary-region</GeoPrimaryRegion> | ||
<StatusOfPrimary>primary-status</StatusOfPrimary> | ||
<LastGeoFailoverTime>DateTime</LastGeoFailoverTime> | ||
<GeoSecondaryRegion>secondary-region</GeoSecondaryRegion> | ||
<StatusOfSecondary>secondary-status</StatusOfSecondary> | ||
<CreationTime>time-of-creation</CreationTime> | ||
<CustomDomains> | ||
<CustomDomain> | ||
<Name>name-of-custom-domain</Name> | ||
</CustomDomain> | ||
</CustomDomains> | ||
<SecondaryReadEnabled>secondary-read-indicator</SecondaryReadEnabled> | ||
<SecondaryEndpoints> | ||
<Endpoint>storage-secondary-service-blob-endpoint</Endpoint> | ||
<Endpoint>storage-secondary-service-queue-endpoint</Endpoint> | ||
<Endpoint>storage-secondary-service-table-endpoint</Endpoint> | ||
</SecondaryEndpoints> | ||
<AccountType>type-of-storage-account</AccountType> | ||
</StorageServiceProperties> | ||
<ExtendedProperties> | ||
<ExtendedProperty> | ||
<Name>property-name</Name> | ||
<Value>property-value</Value> | ||
</ExtendedProperty> | ||
</ExtendedProperties> | ||
<Capabilities> | ||
<Capability>storage-account-capability</Capability> | ||
</Capabilities> | ||
</StorageService>"; | ||
|
||
[TestMethod] | ||
public void ValidateSingleStorageAccount() | ||
{ | ||
FakeAsmRetriever fakeAsmRetriever; | ||
TemplateGenerator templateGenerator; | ||
TestHelper.SetupObjects(out fakeAsmRetriever, out templateGenerator); | ||
|
||
var asmStorageAccountXml = new XmlDocument(); | ||
asmStorageAccountXml.LoadXml(sampleAsmStorageInfo); | ||
var info = new Hashtable(); | ||
info["name"] = "mystorage"; | ||
fakeAsmRetriever.SetResponse("StorageAccount", info, asmStorageAccountXml.SelectNodes("StorageService")); | ||
|
||
var templateStream = new MemoryStream(); | ||
var blobDetailStream = new MemoryStream(); | ||
var artefacts = new AsmArtefacts(); | ||
artefacts.StorageAccounts.Add("mystorage"); | ||
|
||
templateGenerator.GenerateTemplate(TestHelper.TenantId, TestHelper.SubscriptionId, artefacts, new StreamWriter(templateStream), new StreamWriter(blobDetailStream)); | ||
|
||
JObject templateJson = TestHelper.GetJsonData(templateStream); | ||
Assert.AreEqual(1, templateJson["resources"].Children().Count()); | ||
var resource = templateJson["resources"].Single(); | ||
Assert.AreEqual("Microsoft.Storage/storageAccounts", resource["type"].Value<string>()); | ||
Assert.AreEqual("mystoragev2", resource["name"].Value<string>()); | ||
Assert.AreEqual("Antarctica", resource["location"].Value<string>()); | ||
Assert.AreEqual("Standard_LRS", resource["properties"]["accountType"].Value<string>()); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.