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."); }
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."); }
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."); }
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."); }
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"); }
/// <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; }
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"); }
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"); }
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); }
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"); }
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."); }
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."); }
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); }
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."); }
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]); }
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]); }
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."); }