A simple mock task for use with Unit Testing.
Inheritance: net.r_eg.IeXod.UnitTests.MockTaskBase, ITask
コード例 #1
0
        public void CheckMessageFromStreamParsesErrorsAndMessagesCorrectly()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Task          t          = new MockTask();

            t.BuildEngine = mockEngine;

            // This should return true since I am passing a canonical error as the stream
            StringReader sr = new StringReader("error MSB4040: There is no target in the project.");

            t.Log.LogMessagesFromStream(sr, MessageImportance.High).ShouldBeTrue();

            // This should return false since I am passing a canonical warning as the stream
            sr = new StringReader("warning ABCD123MyCode: Felix is a cat.");
            t.Log.LogMessagesFromStream(sr, MessageImportance.Low).ShouldBeFalse();

            // This should return false since I am passing a non canonical message in the stream
            sr = new StringReader("Hello World");
            t.Log.LogMessagesFromStream(sr, MessageImportance.High).ShouldBeFalse();
        }
コード例 #2
0
        public void LogFromResources()
        {
            MockEngine mockEngine = new MockEngine();
            Task       t          = new MockTask();

            t.BuildEngine = mockEngine;

            t.Log.LogErrorFromResources("MySubcategoryResource", null,
                                        "helpkeyword", "filename", 1, 2, 3, 4, "MyErrorResource", "foo");

            t.Log.LogErrorFromResources("MyErrorResource", "foo");

            t.Log.LogWarningFromResources("MySubcategoryResource", null,
                                          "helpkeyword", "filename", 1, 2, 3, 4, "MyWarningResource", "foo");

            t.Log.LogWarningFromResources("MyWarningResource", "foo");

            mockEngine.Log.Contains("filename(1,2,3,4): Romulan error : Oops I wiped your harddrive foo").ShouldBeTrue();
            mockEngine.Log.Contains("filename(1,2,3,4): Romulan warning : Be nice or I wipe your harddrive foo").ShouldBeTrue();
            mockEngine.Log.Contains("Oops I wiped your harddrive foo").ShouldBeTrue();
            mockEngine.Log.Contains("Be nice or I wipe your harddrive foo").ShouldBeTrue();
        }
コード例 #3
0
        public void CheckMessageCode()
        {
            Task t = new MockTask();

            // normal
            string messageOnly;
            string code = t.Log.ExtractMessageCode("AL001: This is a message.", out messageOnly);

            code.ShouldBe("AL001");
            messageOnly.ShouldBe("This is a message.");

            // whitespace before code and after colon is ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("  AL001:   This is a message.", out messageOnly);
            code.ShouldBe("AL001");
            messageOnly.ShouldBe("This is a message.");

            // whitespace after colon is not ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("AL001 : This is a message.", out messageOnly);
            code.ShouldBeNull();
            messageOnly.ShouldBe("AL001 : This is a message.");

            // big code is ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("  RESGEN7905001:   This is a message.", out messageOnly);
            code.ShouldBe("RESGEN7905001");
            messageOnly.ShouldBe("This is a message.");

            // small code is ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("R7: This is a message.", out messageOnly);
            code.ShouldBe("R7");
            messageOnly.ShouldBe("This is a message.");

            // lowercase code is ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("alink3456: This is a message.", out messageOnly);
            code.ShouldBe("alink3456");
            messageOnly.ShouldBe("This is a message.");

            // whitespace in code is not ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("  RES 7905:   This is a message.", out messageOnly);
            code.ShouldBeNull();
            messageOnly.ShouldBe("  RES 7905:   This is a message.");

            // only digits in code is not ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("7905: This is a message.", out messageOnly);
            code.ShouldBeNull();
            messageOnly.ShouldBe("7905: This is a message.");

            // only letters in code is not ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("ALINK: This is a message.", out messageOnly);
            code.ShouldBeNull();
            messageOnly.ShouldBe("ALINK: This is a message.");

            // digits before letters in code is not ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("6780ALINK: This is a message.", out messageOnly);
            code.ShouldBeNull();
            messageOnly.ShouldBe("6780ALINK: This is a message.");

            // mixing digits and letters in code is not ok
            messageOnly = null;
            code        = t.Log.ExtractMessageCode("LNK658A: This is a message.", out messageOnly);
            code.ShouldBeNull();
            messageOnly.ShouldBe("LNK658A: This is a message.");
        }