Пример #1
0
        public void PostCommentStoresAndSetsDates()
        {
            //Given
            var now             = DateTime.Now;
            var todosRepository = new TestTodosRepository {
                Todos = new Dictionary <int, Todo> {
                    { 5, new Todo {
                          Id = 5, TodoComments = new List <TodoComment>()
                      } }
                }
            };
            var todosController = new TodosController(todosRepository);
            var todoComment     = new TodoComment {
                Id = 1, Text = "A comment"
            };
            //When
            var rc = todosController.PostComment(5, todoComment);

            //Then
            Assert.True(1 == rc.Count(), "Count is wrong");
            Assert.True(5 == rc.First().Id, "Id is wrong");
            Assert.True(1 == rc.First().TodoComments.First().Id, "TodoComment.Id is wrong");
            Assert.True(now <= rc.First().TodoComments.First().UpdatedOn, "UpdatedOn should have been set");
            Assert.True(5 == rc.First().TodoComments.First().TodoId, "TodoId is wrong");
        }