예제 #1
0
        public void TestConstructorLogEntryTypeMessage()
        {
            string expectedMessage = "";
            MessageType expectedType = MessageType.Warning;
            DateTime expectedTimestamp = DateTime.Now;
            ApplicationLogEntry testLogEntry = new ApplicationLogEntry(MessageType.Warning, null, new object());
            Assert.IsNotNull(testLogEntry, "Constructor of type, LogEntry failed to create instance.");
            Assert.AreEqual(expectedType, testLogEntry.Type, "Type is unexpected value.");
            Assert.AreEqual(expectedMessage, testLogEntry.Message, "Message is unexpected value.");
            Assert.AreEqual(expectedTimestamp, testLogEntry.Timestamp, "Timestamp is unexpected value.");
            Assert.AreEqual("Object", testLogEntry.Location, "Location is unexpected value.");
            Assert.IsNotNull(testLogEntry.GetHashCode(), "GetHashCode method returned unexpected value.");
            Assert.IsNotNull(testLogEntry.ToString(), "GetHashCode method returned unexpected value.");

            expectedMessage = "Information.";
            expectedType = MessageType.Information;
            expectedTimestamp = DateTime.Now;
            testLogEntry = new ApplicationLogEntry(MessageType.Information, "Information.", new object());
            Assert.IsNotNull(testLogEntry, "Constructor of type, LogEntry failed to create instance.");
            Assert.AreEqual(expectedType, testLogEntry.Type, "Type is unexpected value.");
            Assert.AreEqual(expectedMessage, testLogEntry.Message, "Message is unexpected value.");
            Assert.AreEqual(expectedTimestamp, testLogEntry.Timestamp, "Timestamp is unexpected value.");
            Assert.AreEqual("Object", testLogEntry.Location, "Location is unexpected value.");
            Assert.IsNotNull(testLogEntry.GetHashCode(), "GetHashCode method returned unexpected value.");
            Assert.IsNotNull(testLogEntry.ToString(), "GetHashCode method returned unexpected value.");
        }
예제 #2
0
 public void TestConstructorLogEntryEventArgs()
 {
     ILogEntry entry = new ApplicationLogEntry(MessageType.Warning, null, new object());
     LogEntryEventArgs testLogEntryEventArgs = new LogEntryEventArgs(entry);
     Assert.IsNotNull(testLogEntryEventArgs, "Constructor of type, LogEntryEventArgs failed to create instance.");
     Assert.IsNotNull(testLogEntryEventArgs.LogEntry, "Constructor of type, LogEntryEventArgs failed to create instance.");
     Assert.IsTrue(entry.Equals(testLogEntryEventArgs.LogEntry), "Constructor of type, LogEntryEventArgs failed to create instance.");
 }
예제 #3
0
        public void TestAppend()
        {
            ILogEntry entry = new ApplicationLogEntry(MessageType.Information, "Information", new object());
            _unitUnderTest.Append(entry);

            _unitUnderTest.LogEntryAppended += new LogEntryAppendedEventHandler(_unitUnderTest_LogEntryAppended);
            _unitUnderTest.Append(entry);
            Assert.AreEqual(entry, _unitUnderTest[0], "Count is unexpected value.");
        }
예제 #4
0
        public void TestGetHashCode()
        {
            ApplicationLogEntry testLogEntry1 = new ApplicationLogEntry(MessageType.Warning, "", new object());
            ApplicationLogEntry testLogEntry2 = new ApplicationLogEntry(MessageType.Warning, "", new object());

            int expectedInt32 = testLogEntry1.GetHashCode();
            int resultInt32 = testLogEntry2.GetHashCode();
            Assert.AreEqual(expectedInt32, resultInt32, "GetHashCode method returned unexpected result.");

            resultInt32 = _unitUnderTest.GetHashCode();
            Assert.AreNotEqual(expectedInt32, resultInt32, "GetHashCode method returned unexpected result.");
        }
예제 #5
0
        public void TestEquals()
        {
            ApplicationLogEntry testLogEntry = new ApplicationLogEntry(MessageType.Warning, "", new object());
            object obj = null;
            bool expectedBoolean = false;
            bool resultBoolean = false;
            resultBoolean = testLogEntry.Equals(obj);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = testLogEntry.Equals(testLogEntry);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
        }