示例#1
0
    public void Single_feature_on_off_and_feature_on_and_feature_off()
    {
        var attr = new FeatureTestMethodAttribute(onOff: "A", on: "B", off: "C");

        var testMethod = new MockTestMethod();

        attr.Execute(testMethod);

        Assert.AreEqual(2, testMethod.Executions.Count);

        Assert.AreEqual(3, testMethod.Executions[0].Features.Count);
        Assert.AreEqual("A", testMethod.Executions[0].Features[0].Name);
        Assert.AreEqual(false, testMethod.Executions[0].Features[0].IsOn);
        Assert.AreEqual("B", testMethod.Executions[0].Features[1].Name);
        Assert.AreEqual(true, testMethod.Executions[0].Features[1].IsOn);
        Assert.AreEqual("C", testMethod.Executions[0].Features[2].Name);
        Assert.AreEqual(false, testMethod.Executions[0].Features[2].IsOn);

        Assert.AreEqual(3, testMethod.Executions[1].Features.Count);
        Assert.AreEqual("A", testMethod.Executions[1].Features[0].Name);
        Assert.AreEqual(true, testMethod.Executions[1].Features[0].IsOn);
        Assert.AreEqual("B", testMethod.Executions[1].Features[1].Name);
        Assert.AreEqual(true, testMethod.Executions[1].Features[1].IsOn);
        Assert.AreEqual("C", testMethod.Executions[1].Features[2].Name);
        Assert.AreEqual(false, testMethod.Executions[1].Features[2].IsOn);
    }
示例#2
0
    public void Single_feature_on_off_typed_multiple_onvalues()
    {
        var attr = new FeatureTestMethodAttribute(onOff: "A");

        var testData = new FeatureTestValueAttribute("A", onValues: new object[] { "On1", "On2" }, offValue: "Off");

        var testMethod = new MockTestMethod(new List <Attribute> {
            testData
        });

        attr.Execute(testMethod);

        Assert.AreEqual(3, testMethod.Executions.Count);

        Assert.AreEqual(false, testMethod.Executions[0].Features[0].IsOn);
        Assert.AreEqual("On1", testMethod.Executions[0].Features[0].OnValue);
        Assert.AreEqual("Off", testMethod.Executions[0].Features[0].OffValue);

        Assert.AreEqual(true, testMethod.Executions[1].Features[0].IsOn);
        Assert.AreEqual("On1", testMethod.Executions[1].Features[0].OnValue);
        Assert.AreEqual("Off", testMethod.Executions[1].Features[0].OffValue);

        Assert.AreEqual(true, testMethod.Executions[2].Features[0].IsOn);
        Assert.AreEqual("On2", testMethod.Executions[2].Features[0].OnValue);
        Assert.AreEqual("Off", testMethod.Executions[2].Features[0].OffValue);
    }
示例#3
0
    public void Single_feature_on_off_typed()
    {
        var attr = new FeatureTestMethodAttribute(onOff: "A");

        var testData = new FeatureTestValueAttribute("A", onValue: "On", offValue: "Off");

        var testMethod = new MockTestMethod(new List <Attribute> {
            testData
        });

        attr.Execute(testMethod);

        Assert.AreEqual(2, testMethod.Executions.Count);

        Assert.AreEqual("A", testMethod.Executions[0].Features[0].Name);
        Assert.AreEqual(false, testMethod.Executions[0].Features[0].IsOn);
        Assert.AreEqual("On", testMethod.Executions[0].Features[0].OnValue);
        Assert.AreEqual("Off", testMethod.Executions[0].Features[0].OffValue);
    }
示例#4
0
    public void Two_features_on_off()
    {
        var attr = new FeatureTestMethodAttribute(onOff: "A,B");

        var testMethod = new MockTestMethod();

        attr.Execute(testMethod);

        Assert.AreEqual(4, testMethod.Executions.Count);

        Assert.AreEqual(2, testMethod.Executions[0].Features.Count);
        Assert.AreEqual("A", testMethod.Executions[0].Features[0].Name);
        Assert.AreEqual(false, testMethod.Executions[0].Features[0].IsOn);
        Assert.AreEqual(true, testMethod.Executions[0].Features[0].OnValue);
        Assert.AreEqual(false, testMethod.Executions[0].Features[0].OffValue);
        Assert.AreEqual("B", testMethod.Executions[0].Features[1].Name);
        Assert.AreEqual(false, testMethod.Executions[0].Features[1].IsOn);
        Assert.AreEqual(true, testMethod.Executions[0].Features[1].OnValue);
        Assert.AreEqual(false, testMethod.Executions[0].Features[1].OffValue);

        Assert.AreEqual(2, testMethod.Executions[1].Features.Count);
        Assert.AreEqual("A", testMethod.Executions[1].Features[0].Name);
        Assert.AreEqual(true, testMethod.Executions[1].Features[0].IsOn);
        Assert.AreEqual("B", testMethod.Executions[1].Features[1].Name);
        Assert.AreEqual(false, testMethod.Executions[1].Features[1].IsOn);

        Assert.AreEqual(2, testMethod.Executions[2].Features.Count);
        Assert.AreEqual("A", testMethod.Executions[2].Features[0].Name);
        Assert.AreEqual(false, testMethod.Executions[2].Features[0].IsOn);
        Assert.AreEqual("B", testMethod.Executions[2].Features[1].Name);
        Assert.AreEqual(true, testMethod.Executions[2].Features[1].IsOn);

        Assert.AreEqual(2, testMethod.Executions[3].Features.Count);
        Assert.AreEqual("A", testMethod.Executions[3].Features[0].Name);
        Assert.AreEqual(true, testMethod.Executions[3].Features[0].IsOn);
        Assert.AreEqual("B", testMethod.Executions[3].Features[1].Name);
        Assert.AreEqual(true, testMethod.Executions[3].Features[1].IsOn);
    }