예제 #1
0
    public void EastUS_StringChecks()
    {
        DeploymentRegion eus = DeploymentRegion.EastUS;

        eus.ToRegionName().Should().Be("East US");
        eus.ToRegionCode().Should().Be("EUS");
    }
예제 #2
0
    public void UnrecognizedValue()
    {
        DeploymentRegion sut = (DeploymentRegion)666;

        Assert.Throws <ArgumentException>(() => sut.ToRegionName());
        Assert.Throws <ArgumentException>(() => sut.ToRegionCode());
    }
예제 #3
0
    public void WestEurope_StringChecks()
    {
        DeploymentRegion we = DeploymentRegion.WestEurope;

        we.ToRegionName().Should().Be("West Europe");
        we.ToRegionCode().Should().Be("WE");
    }
예제 #4
0
        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());
        }
예제 #5
0
 /// <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());
 }
예제 #6
0
    public void GetRegionSequence_ForAllEnvironments(DeploymentEnvironment env, DeploymentRegion source, DeploymentRegion[] expected)
    {
        var ret = EswDevOpsSdk.GetRegionSequence(env, source);

        ret.Should().ContainInOrder(expected).And.HaveCount(expected.Length);
    }
예제 #7
0
        // 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);
        }