Exemplo n.º 1
0
    public void EastUS_StringChecks()
    {
        DeploymentRegion eus = DeploymentRegion.EastUS;

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

        Assert.Throws <ArgumentException>(() => sut.ToRegionName());
        Assert.Throws <ArgumentException>(() => sut.ToRegionCode());
    }
Exemplo n.º 3
0
    public void WestEurope_StringChecks()
    {
        DeploymentRegion we = DeploymentRegion.WestEurope;

        we.ToRegionName().Should().Be("West Europe");
        we.ToRegionCode().Should().Be("WE");
    }
Exemplo n.º 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());
        }
Exemplo n.º 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());
 }
Exemplo n.º 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);
    }
Exemplo n.º 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);
        }