public void EastUS_StringChecks() { DeploymentRegion eus = DeploymentRegion.EastUS; eus.ToRegionName().Should().Be("East US"); eus.ToRegionCode().Should().Be("EUS"); }
public void UnrecognizedValue() { DeploymentRegion sut = (DeploymentRegion)666; Assert.Throws <ArgumentException>(() => sut.ToRegionName()); Assert.Throws <ArgumentException>(() => sut.ToRegionCode()); }
public void WestEurope_StringChecks() { DeploymentRegion we = DeploymentRegion.WestEurope; we.ToRegionName().Should().Be("West Europe"); we.ToRegionCode().Should().Be("WE"); }
private static RegionDescriptorAttribute GetAttributeInstance(DeploymentRegion it) { if (!(typeof(DeploymentRegion).IsEnumDefined(it))) { throw new ArgumentException("Unrecognized value"); } FieldInfo fi = it.GetType().GetField(it.ToString()); return((RegionDescriptorAttribute)fi.GetCustomAttributes( typeof(RegionDescriptorAttribute), false).First()); }
/// <summary> /// to short region string value /// </summary> /// <param name="it">enum instance</param> /// <returns>short string value - code - of the region</returns> public static string ToRegionCode(this DeploymentRegion it) { return(GetAttributeInstance(it).ToShortString()); }
public void GetRegionSequence_ForAllEnvironments(DeploymentEnvironment env, DeploymentRegion source, DeploymentRegion[] expected) { var ret = EswDevOpsSdk.GetRegionSequence(env, source); ret.Should().ContainInOrder(expected).And.HaveCount(expected.Length); }
// ReSharper disable once MemberCanBePrivate.Global public static IEnumerable <DeploymentRegion> GetRegionSequence(DeploymentEnvironment environment, DeploymentRegion masterRegion) { if (environment == DeploymentEnvironment.CI) { return new[] { DeploymentRegion.WestEurope } } ; //map region to hierarchy if (!RegionSequenceMap.ContainsKey(masterRegion)) { throw new DevOpsSDKException($"Unrecognized value for region environmental variable - {masterRegion}"); } var map = RegionSequenceMap[masterRegion]; return((environment == DeploymentEnvironment.Sand || environment == DeploymentEnvironment.Test || environment == DeploymentEnvironment.Development) ? map.Where(r => r != DeploymentRegion.SoutheastAsia) : map); }