Beispiel #1
0
    public static void WithTestNode_OutputResultsInOutputMessage()
    {
        var messages = new List <_MessageSinkMessage>();
        var sink     = SpyMessageSink.Create(messages: messages);
        var testCase = CreateTestCase("assembly", "config", "foo", "bar", "foo.bar");
        var handler  = new TestClassCallbackHandler(new[] { testCase }, sink);
        var startXml = new XmlDocument();

        startXml.LoadXml("<start type='foo' method='bar' name='foo.bar'></start>");
        var passXml = new XmlDocument();

        passXml.LoadXml("<test type='foo' method='bar' name='foo.bar' time='1.234' result='Pass'><output>This is output text</output></test>");

        handler.OnXmlNode(startXml.FirstChild);
        handler.OnXmlNode(passXml.FirstChild);

        var message = Assert.Single(messages.OfType <_TestOutput>());

        Assert.Equal("This is output text", message.Output);
    }
Beispiel #2
0
    public static void WithTestNode_ParsesNumberWithInvariantCulture()
    {
        var messages = new List <_MessageSinkMessage>();
        var sink     = SpyMessageSink.Create(messages: messages);
        var testCase = CreateTestCase("assembly", "config", "foo", "bar", "foo.bar");
        var handler  = new TestClassCallbackHandler(new[] { testCase }, sink);
        var startXml = new XmlDocument();

        startXml.LoadXml("<start type='foo' method='bar' name='foo.bar'></start>");
        var passXml = new XmlDocument();

        passXml.LoadXml("<test type='foo' method='bar' name='foo.bar' time='1.234' result='Pass' />");

        handler.OnXmlNode(startXml.FirstChild);
        handler.OnXmlNode(passXml.FirstChild);

        var message = Assert.Single(messages.OfType <_TestFinished>());

        Assert.Equal(1.234M, message.ExecutionTime);
    }
Beispiel #3
0
    public static void WithClassNode_ParsesNumbersWithInvariantCulture()
    {
        var handler = new TestClassCallbackHandler(new Xunit1TestCase[0], Substitute.For <IMessageSink>());
        var xml     = new XmlDocument();

        xml.LoadXml("<class time='1.234' total='4' failed='3' skipped='2' />");

        handler.OnXmlNode(xml.FirstChild);

        Assert.Equal(1.234M, handler.TestClassResults.Time);
        Assert.Equal(4, handler.TestClassResults.Total);
        Assert.Equal(3, handler.TestClassResults.Failed);
        Assert.Equal(2, handler.TestClassResults.Skipped);
    }
Beispiel #4
0
    public static void WithTestNode_ParsesNumberWithInvariantCulture()
    {
        var sink     = Substitute.For <IMessageSink>();
        var testCase = new Xunit1TestCase("assembly", "config", "foo", "bar", "foo.bar");
        var handler  = new TestClassCallbackHandler(new [] { testCase }, sink);
        var xml      = new XmlDocument();

        xml.LoadXml("<test type='foo' method='bar' name='foo.bar' time='1.234' result='Pass' />");

        handler.OnXmlNode(xml.FirstChild);

        var args    = sink.Captured(1, x => x.OnMessage(null));
        var message = args.Arg <ITestFinished>();

        Assert.Equal(1.234M, message.ExecutionTime);
    }
Beispiel #5
0
    public static void WithTestNode_OutputResultsInOutputMessage()
    {
        var sink     = Substitute.For <IMessageSink>();
        var testCase = new Xunit1TestCase("assembly", "config", "foo", "bar", "foo.bar");
        var handler  = new TestClassCallbackHandler(new[] { testCase }, sink);
        var xml      = new XmlDocument();

        xml.LoadXml("<test type='foo' method='bar' name='foo.bar' time='1.234' result='Pass'><output>This is output text</output></test>");

        handler.OnXmlNode(xml.FirstChild);

        var args    = sink.Captured(0, x => x.OnMessage(null));
        var message = args.Arg <ITestOutput>();

        Assert.Same(testCase, message.TestCase);
        Assert.Equal("This is output text", message.Output);
    }