Exemple #1
0
    public void WriteLine(string outputText, string expected)
    {
        var output     = new TestOutputHelper();
        var messageBus = new SpyMessageBus();
        var test       = Substitute.For <_ITest>();

        test.UniqueID.Returns("test-id");
        test.TestCase.UniqueID.Returns("case-id");
        test.TestCase.TestMethod !.UniqueID.Returns("method-id");
        test.TestCase.TestClass !.UniqueID.Returns("class-id");
        test.TestCase.TestCollection.UniqueID.Returns("coll-id");
        test.TestCase.TestCollection.TestAssembly.UniqueID.Returns("asm-id");
        output.Initialize(messageBus, test);

        output.WriteLine(outputText);

        var message       = Assert.Single(messageBus.Messages);
        var outputMessage = Assert.IsType <_TestOutput>(message);

        Assert.Equal("asm-id", outputMessage.AssemblyUniqueID);
        Assert.Equal(expected + Environment.NewLine, outputMessage.Output);
        Assert.Equal("case-id", outputMessage.TestCaseUniqueID);
        Assert.Equal("class-id", outputMessage.TestClassUniqueID);
        Assert.Equal("coll-id", outputMessage.TestCollectionUniqueID);
        Assert.Equal("method-id", outputMessage.TestMethodUniqueID);
        Assert.Equal("test-id", outputMessage.TestUniqueID);
        Assert.Equal(expected + Environment.NewLine, output.Output);
    }