public void IsApplicable_WhenNoGatesSpecified_NoApplicableGatesReturned() { UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; GatesAny gateCombination = new GatesAny(); Assert.False(gateCombination.IsApplicable(context, out IGate[] gates), "No gates should be applicable"); Assert.Null(gates); }
public void IsApplicable_WithOneNotApplicable_ReturnsNoApplicableGate() { Gate notApplicableGate = new Gate("notApplicable1"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; GatesAny gateCombination = new GatesAny(notApplicableGate); Assert.False(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be false"); Assert.Null(gates); }
public void IsApplicable_WithOneApplicableGate_ReturnsTheApplicableGate() { Gate applicableGate = new Gate("applicable1"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new string[] { applicableGate.Name }; GatesAny gateCombination = new GatesAny(applicableGate); Assert.True(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be true"); Assert.Same(applicableGate, gates[0]); }
public void IsApplicable_WithOneApplicableGate_ReturnsNoApplicableGate() { Gate applicableGate = new Gate("applicable1"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new string[] { applicableGate.Name }; GatesNone gateCombination = new GatesNone(applicableGate); Assert.False(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be false"); Assert.Null(gates); }
public void IsApplicable_WithOneApplicableGate_NoApplicableGatesReturned() { Gate applicableGate = new Gate("applicable1"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new[] { applicableGate.Name }; GatesAll gateCombination = new GatesAll(applicableGate); Assert.True(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be true."); Assert.NotNull(gates); }
public void IsApplicable_WithTwoApplicableGates_ReturnsFirstApplicableGate() { Gate applicableGate1 = new Gate("applicable1"); Gate applicableGate2 = new Gate("applicable2"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new string[] { applicableGate1.Name, applicableGate2.Name }; GatesAny gateCombination = new GatesAny(applicableGate1, applicableGate2); Assert.True(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be true"); Assert.Same(applicableGate1, gates[0]); }
public void IsApplicable_WithTwoNotApplicableGates_ReturnsFailureForApplicableGates() { Gate notApplicableGate1 = new Gate("notApplicable1"); Gate notApplicableGate2 = new Gate("notApplicable2"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new string[] { }; GatesAny gateCombination = new GatesAny(notApplicableGate1, notApplicableGate2); Assert.False(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be false"); Assert.Null(gates); }
public void IsApplicable_WitOneGateNotApplicable_NoGatesReturned() { Gate applicableGate = new Gate("applicable1"); Gate nonApplicableGate = new Gate("nonApplicable"); Gate applicableGate2 = new Gate("applicable2"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new[] { applicableGate.Name, applicableGate2.Name }; GatesAll gateCombination = new GatesAll(applicableGate, nonApplicableGate, applicableGate2); Assert.False(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be false."); Assert.Null(gates); }
public void GatedCode_IntitialzedWithNullObject_NonApplicableGatesShouldBeReturnedApplicableUsingGatesProperty() { // Gates property intialized with GatesNone object. GatedCode gatedCode = new GatedCode((IGate)null); UnitTestGateContext gateContext = new UnitTestGateContext { AlwaysReturnApplicable = false, ApplicableGates = new List <string>() { "Test.Gate1", "Test.Gate2" } }; Assert.True(gatedCode.Gates.IsApplicable(gateContext, out IGate[] gates), "Returns true as no gate was applicable."); Assert.Null(gates); }
public void GatedCode_UsingGateWithoutReleasePlan_NonApplicableGateReturnedNonApplicableUsingGatesProperty() { // Gates property intialized with GatesAny object. GatedCode gatedCode = new GatedCode(new Gate("Test.Gate1")); UnitTestGateContext gateContext = new UnitTestGateContext { AlwaysReturnApplicable = false, ApplicableGates = new List <string>() { "Test.Gate2", "Test.Gate3" } }; Assert.False(gatedCode.IsBaselineCode, "Shouldn't be a baseline code as its gated."); Assert.False(gatedCode.Gates.IsApplicable(gateContext, out IGate[] gates), "Returns false as no gate was applicable."); Assert.Null(gates); }
public void GatedCode_UsingGateWithoutReleasePlan_ApplicableGateReturnedApplicableUsingGatesProperty() { // Gates property intialized with GatesAny object. GatedCode gatedCode = new GatedCode(new Gate("Test.Gate1")); UnitTestGateContext gateContext = new UnitTestGateContext { AlwaysReturnApplicable = false, ApplicableGates = new List <string>() { "Test.Gate1", "Test.Gate2" } }; Assert.False(gatedCode.IsBaselineCode, "Shouldn't be a baseline code as its gated."); Assert.True(gatedCode.Gates.IsApplicable(gateContext, out IGate[] gates), "Returns true with first applicable gate"); Assert.Equal("Test.Gate1", gates.First().FullyQualifiedName); }
public void IsApplicable_WitAllGatesApplicable_AllGatesReturned() { Gate applicableGate = new Gate("applicable1"); Gate applicableGate2 = new Gate("applicable2"); Gate applicableGate3 = new Gate("applicable3"); UnitTestGateContext context = new UnitTestGateContext { AlwaysReturnApplicable = false }; context.ApplicableGates = new[] { applicableGate.Name, applicableGate2.Name, applicableGate3.Name }; GatesAll gateCombination = new GatesAll(applicableGate, applicableGate2, applicableGate3); Assert.True(gateCombination.IsApplicable(context, out IGate[] gates), "Get applicable gates should be true."); Assert.NotNull(gates); Assert.Same(gates[0], applicableGate); Assert.Same(gates[1], applicableGate2); Assert.Same(gates[2], applicableGate3); }
public void GatedCode_UsingGateWithReleasePlanHavingNoApplicableReleaseGates_NoApplicableReleaseGateReturnedUsingGatesProperty() { GateDataSet gateDataSet = LoadGateDataSet(GateXmlWithReleaseGates); // Gates property intialized with GatesNone object. GatedCode gatedCode = new GatedCode(gateDataSet.GetGate("MyProduct.Test.ReleasePlan")); UnitTestGateContext gateContext = new UnitTestGateContext { AlwaysReturnApplicable = false, ApplicableGates = new List <string>() { "MyProduct.Test.ReleasePlan", } }; Assert.False(gatedCode.IsBaselineCode, "Shouldn't be a baseline code as its gated."); Assert.False(gatedCode.Gates.IsApplicable(gateContext, out IGate[] gates), "Returns false as no release gate applicable"); Assert.Null(gates); }
public void GatedCode_UsingGateWithReleasePlanHavingApplicableReleaseGates_FirstApplicableReleaseGateReturnedUsingGatesProperty() { GateDataSet gateDataSet = LoadGateDataSet(GateXmlWithReleaseGates); // Gates property intialized with GatesAny object. GatedCode gatedCode = new GatedCode(gateDataSet.GetGate("MyProduct.Test.ReleasePlan")); UnitTestGateContext gateContext = new UnitTestGateContext { AlwaysReturnApplicable = false, ApplicableGates = new List <string>() { "MyProduct.Test.ReleasePlan", "MyProduct.WebSite.Feature.ReleasePlan.Integration" } }; Assert.False(gatedCode.IsBaselineCode, "Shouldn't be a baseline code as its gated."); Assert.True(gatedCode.Gates.IsApplicable(gateContext, out IGate[] gates), "Returns true with first applicable release gate."); Assert.Equal("MyProduct.WebSite.Feature.ReleasePlan.Integration", gates.First().FullyQualifiedName); }