コード例 #1
0
 public void MinimalTest()
 {
     InvokeActivity.AddMessage("HeyHeyHey");
     Assert.AreEqual(MessageRepository.Instance.Messages.Count, 1);
     InvokeActivity.TruncateMessages();
     Assert.AreEqual(MessageRepository.Instance.Messages.Count, 0);
 }
コード例 #2
0
 public void MinimalTest()
 {
     InvokeActivity.AddDefaultTags("some-tag");
     Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 1);
     InvokeActivity.ClearDefaultTags();
     Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 0);
 }
コード例 #3
0
        public void MinimalTest()
        {
            InvokeActivity.SetDefaultTransactionId("1");
            Assert.AreEqual(MessageRepository.Instance.DefaultTransactionId, "1");

            MessageRepository.Instance.Reset();
        }
コード例 #4
0
        public void CustomPropertiesTest()
        {
            var props = new System.Collections.Generic.Dictionary <string, object>()
            {
                { "Face", "Happy" }
            };

            InvokeActivity.AddMessage(":)", customProperties: props, level: LogLevel.Info);

            props = new System.Collections.Generic.Dictionary <string, object>()
            {
                { "Face", "Sad" }
            };
            InvokeActivity.AddMessage(":(", customProperties: props, level: LogLevel.Info);

            props = new System.Collections.Generic.Dictionary <string, object>()
            {
                { "Palindrome", true }
            };
            InvokeActivity.AddMessage("TacoCat", customProperties: props, level: LogLevel.Info);

            var allMessages = (DataTable)InvokeActivity.OutputReport()["DataTable"];

            Assert.AreEqual(allMessages.Rows.Count, 3);
            Assert.IsTrue(allMessages.Columns.Contains("Face"));
            Assert.IsTrue(allMessages.Columns.Contains("Palindrome"));
            Assert.AreEqual(allMessages.Select("Message = 'TacoCat'").First()["Face"], DBNull.Value);
            Assert.AreEqual(allMessages.Select("Message = 'TacoCat'").First()["Palindrome"], true.ToString());

            MessageRepository.Instance.Reset();
        }
コード例 #5
0
        public void TransactionIdFilterTest()
        {
            InvokeActivity.AddMessage(":) 1", transactionId: "1", level: LogLevel.Info);
            InvokeActivity.AddMessage(":) 2", transactionId: "2", level: LogLevel.Info);
            InvokeActivity.AddMessage(":) 2", transactionId: "2", level: LogLevel.Info);
            InvokeActivity.AddMessage(":) 3", transactionId: "3", level: LogLevel.Info);

            var allMessages = (DataTable)InvokeActivity.OutputReport()["DataTable"];

            Assert.AreEqual(allMessages.Rows.Count, 4);

            var id1 = (DataTable)InvokeActivity.OutputReport(transactionIdFilter: new [] { "1" })["DataTable"];

            Assert.AreEqual(id1.Rows.Count, 1);

            var id2 = (DataTable)InvokeActivity.OutputReport(transactionIdFilter: new[] { "2" })["DataTable"];

            Assert.AreEqual(id2.Rows.Count, 2);

            var id1and2 = (DataTable)InvokeActivity.OutputReport(transactionIdFilter: new[] { "1", "2" })["DataTable"];

            Assert.AreEqual(id1and2.Rows.Count, 3);

            MessageRepository.Instance.Reset();
        }
コード例 #6
0
        public void MinimalTypedTest()
        {
            InvokeActivity.AddMessage(":)", level: LogLevel.Info);
            var table = (DataTable)InvokeActivity.OutputReport(minLogLevel: LogLevel.Info, plaintext: false)["DataTable"];

            Assert.AreEqual(table.Rows.Count, 1);

            MessageRepository.Instance.Reset();
        }
コード例 #7
0
        public void AddSingleTagTest()
        {
            var tag = "some-tag";

            InvokeActivity.AddDefaultTags(tag: tag);

            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 1);
            Assert.AreEqual(MessageRepository.Instance.DefaultTags[0], tag);

            MessageRepository.Instance.Reset();
        }
コード例 #8
0
        public void MinimalTest()
        {
            var message = "Hi";

            InvokeActivity.AddMessage(message);

            Assert.AreEqual(MessageRepository.Instance.Messages.Count, 1);
            Assert.AreEqual(MessageRepository.Instance.Messages.First().Text, message);

            MessageRepository.Instance.Messages.Clear();
        }
コード例 #9
0
        public void MinimalTest()
        {
            InvokeActivity.AddDefaultTags(tags: new[] { "hi", "bye" });
            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 2);
            InvokeActivity.RemoveDefaultTags(tags: new[] { "hi", "hey" });
            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 1);
            InvokeActivity.RemoveDefaultTags(tags: new[] { "bye" });
            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 0);

            MessageRepository.Instance.Reset();
        }
コード例 #10
0
        public void AddMultipleTagsTest()
        {
            var tags = new[] { "tag1", "tag2" };

            InvokeActivity.AddDefaultTags(tags: tags);

            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 2);
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains(tags[0]));
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains(tags[1]));

            MessageRepository.Instance.Reset();
        }
コード例 #11
0
        //[TestMethod]
        public void AddLotsOfMessagesTest()
        {
            var numberOfMessages = 1_000_000;

            foreach (var i in Enumerable.Range(0, numberOfMessages))
            {
                InvokeActivity.AddMessage("This is a kinda looooooooong messsage. Kinda. Not really.");
            }

            Assert.AreEqual(MessageRepository.Instance.Messages.Count, numberOfMessages);
            MessageRepository.Instance.Messages.Clear();
        }
コード例 #12
0
        public void TagsMadeDistinctTest()
        {
            var tags = new[] { "tag1", "tag2", "tag1", "tag2", "tag3" };

            InvokeActivity.AddDefaultTags(tags: tags);

            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 3);
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains("tag1"));
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains("tag2"));
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains("tag3"));

            MessageRepository.Instance.Reset();
        }
コード例 #13
0
        public void MinimalTest()
        {
            InvokeActivity.AddDefaultTags("tag1");

            InvokeActivity.SetDefaultTags("tag2");
            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 1);
            Assert.AreEqual(MessageRepository.Instance.DefaultTags[0], "tag2");

            InvokeActivity.SetDefaultTags(tags: new[] { "tag3", "tag4" });
            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 2);
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains("tag3"));
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains("tag4"));
        }
コード例 #14
0
        public void IgnoreTagIfTagsProvided()
        {
            var tag  = "tag0";
            var tags = new[] { "tag1", "tag2" };

            InvokeActivity.AddDefaultTags(tag, tags);

            Assert.AreEqual(MessageRepository.Instance.DefaultTags.Count, 2);
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains(tags[0]));
            Assert.IsTrue(MessageRepository.Instance.DefaultTags.Contains(tags[1]));
            Assert.IsFalse(MessageRepository.Instance.DefaultTags.Contains(tag));

            MessageRepository.Instance.Reset();
        }
コード例 #15
0
        public void TagFilterTest()
        {
            InvokeActivity.AddMessage(":)", tags: new[] { "face", "positive" }, level: LogLevel.Info);
            InvokeActivity.AddMessage(":(", tags: new[] { "face", "negative" }, level: LogLevel.Info);
            InvokeActivity.AddMessage("Good", tags: new[] { "word", "positive" }, level: LogLevel.Info);

            var allMessages = (DataTable)InvokeActivity.OutputReport()["DataTable"];

            Assert.AreEqual(allMessages.Rows.Count, 3);

            var faceMessages = (DataTable)InvokeActivity.OutputReport(tagFilter: new[] { "face" })["DataTable"];

            Assert.AreEqual(faceMessages.Rows.Count, 2);

            var wordMessages = (DataTable)InvokeActivity.OutputReport(tagFilter: new[] { "word" })["DataTable"];

            Assert.AreEqual(wordMessages.Rows.Count, 1);

            var positiveMessages = (DataTable)InvokeActivity.OutputReport(tagFilter: new[] { "positive" })["DataTable"];

            Assert.AreEqual(positiveMessages.Rows.Count, 2);

            var negativeMessages = (DataTable)InvokeActivity.OutputReport(tagFilter: new[] { "negative" })["DataTable"];

            Assert.AreEqual(negativeMessages.Rows.Count, 1);

            var positiveWordsMessages = (DataTable)InvokeActivity.OutputReport(tagFilter: new[] { "positive", "word" })["DataTable"];

            Assert.AreEqual(positiveWordsMessages.Rows.Count, 1);

            var noMessages = (DataTable)InvokeActivity.OutputReport(tagFilter: new[] { "positive", "negative" })["DataTable"];

            Assert.AreEqual(noMessages.Rows.Count, 0);

            MessageRepository.Instance.Reset();
        }