Exemple #1
0
        public void AddMessage_Duplicate_ObserversNotNotified()
        {
            const string message      = "Looking for car share.";
            var          messageBoard = new MessageBoard();
            var          observerMock = new Mock <IMessageBoardObserver>();

            messageBoard.AddMessage(message);
            messageBoard.Attach(observerMock.Object);

            messageBoard.AddMessage(message);

            observerMock.Verify(
                o => o.Update(It.IsAny <IEnumerable <string> >()), Times.Never);
        }
Exemple #2
0
        public void AddMessage_NullMessage_ArgumentNullException()
        {
            var messageBoard = new MessageBoard();
            var ex           = Assert.Throws <ArgumentNullException>(() => messageBoard.AddMessage(null));

            Assert.That(ex.ParamName, Is.EqualTo(AddMessageMessageParam));
        }
Exemple #3
0
        public void AddMessage_EmptyMessage_ArgumentException()
        {
            var messageBoard = new MessageBoard();
            var ex           = Assert.Throws <ArgumentException>(() => messageBoard.AddMessage(string.Empty));

            Assert.That(ex.ParamName, Is.EqualTo(AddMessageMessageParam));
        }
Exemple #4
0
        public void RemoveMessage_ObserversNotified()
        {
            const string message1     = "Cat for sale.";
            const string message2     = "Dog for sale.";
            var          messageBoard = new MessageBoard();
            var          observerMock = new Mock <IMessageBoardObserver>();

            messageBoard.AddMessage(message1);
            messageBoard.AddMessage(message2);
            messageBoard.Attach(observerMock.Object);

            messageBoard.RemoveMessage(message1);

            observerMock.Verify(
                o => o.Update(It.Is <IEnumerable <string> >(e => e.Single() == message2)), Times.Once);
        }
Exemple #5
0
        public void AddMessage_ObserversNotified()
        {
            const string message      = "Room for rent.";
            var          messageBoard = new MessageBoard();
            var          observerMock = new Mock <IMessageBoardObserver>();

            messageBoard.Attach(observerMock.Object);

            messageBoard.AddMessage(message);

            observerMock.Verify(
                o => o.Update(It.Is <IEnumerable <string> >(e => e.Single() == message)), Times.Once);
        }