public void CanConvertProfieWithCustomEnvironment() { IAzureContext context = new AzureContext(new AzureSubscription(), new AzureAccount(), new AzureEnvironment(), new AzureTenant(), new byte[0]); var testContext = new PSAzureContext(context); var testEnvironment = new PSAzureEnvironment(AzureEnvironment.PublicEnvironments["AzureCloud"]); testEnvironment.Name = "ExtraEnvironment"; var testProfile = new PSAzureProfile(); testProfile.Context = testContext; testProfile.Environments.Add("ExtraEnvironment", testEnvironment); ConvertAndTestProfile(testProfile, (profile) => { Assert.NotEmpty(profile.EnvironmentTable); Assert.True(profile.EnvironmentTable.ContainsKey("ExtraEnvironment")); Assert.NotEmpty(profile.Contexts); Assert.NotNull(profile.DefaultContext); Assert.NotEmpty(profile.DefaultContextKey); Assert.Equal("Default", profile.DefaultContextKey); Assert.Collection(profile.Environments.OrderBy(e => e.Name), (e) => Assert.Equal(e, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureChinaCloud]), (e) => Assert.Equal(e, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud]), (e) => Assert.Equal(e, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureGermanCloud]), (e) => Assert.Equal(e, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureUSGovernment]), (e) => Assert.Equal(e, testEnvironment)); }); }
public void CanConvertFullProfilet() { var context = GetDefaultContext(); var prof = new PSAzureProfile(); prof.Context = new PSAzureContext(context); ConvertAndTestProfile(prof, (profile) => { AssertStandardEnvironments(profile); Assert.True(context.IsEqual(profile.DefaultContext)); }); }
public void CanConvertProfileNullComponent() { var context = GetDefaultContext(); context.Subscription = null; var prof = new PSAzureProfile(); prof.Context = new PSAzureContext(context); ConvertAndTestProfile(prof, (profile) => { AssertStandardEnvironments(profile); Assert.True(context.IsEqual(profile.DefaultContext)); }); }