예제 #1
0
        public void IsGateApplicable_WhenGateIsDisabled_ReturnFalse()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 0);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.DisabledGate")),
                         "Gate is disabled through the enabled flag in the xml.");
        }
예제 #2
0
        public void IsGateApplicable_OnSupplyChainServiceWithNoneServiceFlag_ReturnsGateToBeNotApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation("ServiceFive"), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.Services")),
                         "Gate should be not applicable for supplychain service as service flag is set to none.");
        }
예제 #3
0
        public void IsGateApplicable_OnCoSubRetailerCanaryService_ReturnsGateToBeApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation("ServiceTwo", true), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.Services")),
                        "Gate should not be applicable for cosubretailer canary service.");
        }
예제 #4
0
        public void IsGateApplicable_OnDataStoreService_ReturnsGateToBeApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation("ServiceFour"), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.Services")),
                        "Gate should be applicable for datastore service.");
        }
예제 #5
0
        public void IsGateApplicable_ForNoServiceDescribedInGateOnRetailerService_ReturnsGateToBeNotApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.ServicesWithOutAnyService")),
                         "Gate should not be applicable when service tag doesn't have any service");
        }
예제 #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="request">request</param>
 /// <param name="machineInformation">machine information</param>
 /// <param name="experimentContext">experiment context</param>
 /// <param name="knownIpAddresses">known ip addresses</param>
 /// <param name="settings">GateSettings</param>
 public GateContext(IGatedRequest request, IMachineInformation machineInformation, IExperimentContext experimentContext, INamedIPAddresses knownIpAddresses = null, IGateSettings settings = null)
 {
     Request            = request;
     MachineInformation = machineInformation;
     ExperimentContext  = experimentContext;
     KnownIpAddresses   = knownIpAddresses;
     m_settings         = settings;
 }
예제 #7
0
        public void IsGateApplicable_GateWithDates_ReturnCorrectly()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 8);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("CorrectDate")), "Gate with correct dates should be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("BeforeStartDate")), "Gate Before Start Date should  ot be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("AfterEndDate")), "Gate after end date should not be applicable");
        }
예제 #8
0
        public void RequestWithEnvironment_Specified()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 8);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.NoEnvironment")), "Gate with no environment restrictions should be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.ReqEnvironment")), "Gate with environment restrictions should be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("DogfoodApps")), "Gate with environment restrictions and no client version restrictions should be applicable");
        }
예제 #9
0
		public void IsApplicable_ForNotApplicableReleaseGates_NoReleaseGateReturned()
		{
			IGatedRequest gateRequest = SetupGateRequest("ClientThree", "16.3.0.0", "en-us");
			GateContext context = new GateContext(gateRequest, new BasicMachineInformation(), new DefaultExperimentContext());
			IGate gate = Dataset.GetGate("MyProduct.Test.ReleasePlan");
			GatesAny gates = new GatesAny(gate.ReleasePlan);

			Assert.False(gates.IsApplicable(context, out IGate[] applicableReleaseGates), "Gate should be not applicable");
			Assert.Null(applicableReleaseGates);
		}
예제 #10
0
        public void RequestWithCloudContext_Specified()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 8, cloudContext: new HashSet <string> {
                "Public"
            });
            GateContext context = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.CloudContextPublic")), "Gate with cloud context restrictions should be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.CloudContextSovereign")), "Gate with different cloud context restrictions should not be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("DogfoodApps")), "Gate without a cloud context should be applicable");
        }
예제 #11
0
        public void IsGateApplicable_GateWithDisabledSetting_ReturnFalse()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 0);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext(), null,
                                                         new UnitTestGateSettings(null, new List <string> {
                "MyProduct.Test.EnabledGate"
            }));

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.EnabledGate")),
                         "Gate explicitly disabled should not be applicable.");
        }
예제 #12
0
        public void IsGateApplicable_EnablingDisabledGateThroughSettingsForApplicableGate_ReturnsTrue()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 0);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext(), null,
                                                         new UnitTestGateSettings(null, null, new List <string> {
                "MyProduct.Test.ApplicableDisabledGate"
            }));

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.ApplicableDisabledGate")),
                        "Disabled gate enabled through settings and after applicablity check is returned as applicable.");
        }
예제 #13
0
		public void IsApplicable_ContainterGateIsNotApplicable_NoReleaseGateReturned()
		{
			IGatedRequest gateRequest = SetupGateRequest("ClientThree", "16.3.0.0", "en-gb");
			GateContext context = new GateContext(gateRequest, new BasicMachineInformation(), new DefaultExperimentContext());

			GateDataSet dataSet = LoadGateDataSet(ReleaseGateXml);
			IGate gate = dataSet.GetGate("MyProduct.Test.ReleasePlan");
			GatesAny gates = new GatesAny(gate.ReleasePlan);

			Assert.False(gates.IsApplicable(context, out IGate[] applicableReleaseGates), "Gate should not be applicable");
			Assert.Null(applicableReleaseGates);
		}
예제 #14
0
        public void IsGateApplicable_GateWithAppAudienceGroup_ReturnsNotApplicable()
        {
            HashSet <string> audienceGroups = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
            {
                "AppLoop"
            };

            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.0.0.0", "en-us", null, 0, audienceGroups);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.NoEnvironment")), "Gate should not be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.LoopUser")), "Gate should not be applicable for audience group.");
        }
예제 #15
0
		public void IsApplicable_ContainterGateIsApplicable_ApplicableReleaseGateReturned()
		{
			IGatedRequest gateRequest = SetupGateRequest("ClientThree", "16.3.0.0", "en-us", "PreProduction", new[] { new GatedUser { UserIdentifier = "*****@*****.**" } });
			GateContext context = new GateContext(gateRequest, new BasicMachineInformation(), new DefaultExperimentContext());

			GateDataSet dataSet = LoadGateDataSet(ReleaseGateXml);
			IGate gate = dataSet.GetGate("MyProduct.Test.ReleasePlan");
			GatesAny gates = new GatesAny(gate.ReleasePlan);

			Assert.True(gates.IsApplicable(context, out IGate[] applicableReleaseGates), "Gate should be applicable");

			Assert.NotNull(applicableReleaseGates);
			Assert.Same(applicableReleaseGates[0], gate.ReleasePlan[0]);
		}
예제 #16
0
		public void IsApplicable_ForApplicableReleaseGate_ApplicableReleaseGateReturned()
		{
			IGatedRequest gateRequest = SetupGateRequest("ClientThree", "16.3.0.0", "en-us");
			GateContext context = new GateContext(gateRequest, new BasicMachineInformation(), new DefaultExperimentContext(), null,
				new UnitTestGateSettings(new List<string> { "MyProduct.WebSite.Feature.ReleasePlan.Integration" }));

			IGate gate = Dataset.GetGate("MyProduct.Test.ReleasePlan");
			GatesAny gates = new GatesAny(gate.ReleasePlan);

			Assert.True(gates.IsApplicable(context, out IGate[] applicableReleaseGates), "Gate should be applicable");

			Assert.NotNull(applicableReleaseGates);
			Assert.Same(applicableReleaseGates[0], gate.ReleasePlan[0]);
		}
예제 #17
0
        public void IsGateApplicable_GateRequestWithRequestedGates_ReturnsApplicable()
        {
            HashSet <string> requestedGates = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
            {
                "MyProduct.Test.DogfoodUsers",
                "MyProduct.Test.LiveIdUser",
            };

            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0, null, requestedGates);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.NoUsers")), "Gate disabled for all users should not be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.OrgIdUser")), "Gate enabled for OrgId users should not be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.DogfoodUsers")), "Requested gate enabled for Dogfood users should be applicable.");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.LiveIdUser")), "Requested gate enabled for LiveId users should be applicable.");
        }