示例#1
0
        public void AddMessage_Always_ShouldAddMessageToList()
        {
            // Arrange
            var result = new Result();
            var originalMessage = "the original message";
            result.Message = originalMessage;
            var newMessage = "new message";

            // Act
            result.AddMessage( newMessage );

            // Assert
            Assert.AreEqual( 2, result.GetMessages().Count() );
            Assert.AreEqual( originalMessage, result.GetMessages().ElementAt( 0 ) );
            Assert.AreEqual( newMessage, result.GetMessages().ElementAt( 1 ) );
        }
示例#2
0
        public void MessageGet_GivenListOfMessages_ShouldReturnMessagesOnMultipleLines()
        {
            // Arrange
            var result = new Result();
            string firstMessage = "first message";
            string secondMessage = "second message";
            result.AddMessage( firstMessage );
            result.AddMessage( secondMessage );

            // Act
            var message = result.Message;

            // Assert
            var splitMessage = message.Split(
                new[] { Environment.NewLine },
                StringSplitOptions.RemoveEmptyEntries );

            Assert.AreEqual( firstMessage, splitMessage[0] );
            Assert.AreEqual( secondMessage, splitMessage[01] );
        }
示例#3
0
        public void GetMessages_Always_ReturnsMessageList()
        {
            // Arrange
            var result = new Result();
            var firstMessage = "first message";
            var secondMessage = "second message";
            result.AddMessage( firstMessage );
            result.AddMessage( secondMessage );

            // Act
            var messages = result.GetMessages().ToList();

            // Asset
            Assert.AreEqual( 2, messages.Count() );
            Assert.AreEqual( firstMessage, messages.ElementAt( 0 ) );
            Assert.AreEqual( secondMessage, messages.ElementAt( 1 ) );
        }