Example #1
0
        public void Save_WhenCalled_ReturnRedirectToRouteResult()
        {
            var viewModel = GetExistingTopicFormViewModel();

            var result = _controller.Save(viewModel);

            Assert.That(result, Is.TypeOf <RedirectToRouteResult>());
        }
Example #2
0
        public void Save_NewTopic_ShouldAddToDatabase()
        {
            var topic = new Topic {
                Name        = "Test Topic",
                Description = "Test desc"
            };

            var viewModel = new TopicFormViewModel {
                Topic = topic
            };

            _controller.Save(viewModel);

            var topicFromDb = _contextAfterAction.Topics.SingleOrDefault(t => t.Name == topic.Name);

            Assert.That(topicFromDb.Id, Is.Not.Null);
            Assert.That(topicFromDb.Name, Is.EqualTo(topic.Name));
            Assert.That(topicFromDb.Description, Is.EqualTo(topic.Description));
        }