public void create_should_add_flash_message_if_save_is_successful()
 {
     var mockService = new Mock<IMessageService>();
     mockService.Expect(s => s.Add(model)).Returns(1);
     controller = new MessageController(mockService.Object, null);
     var result = controller.Create(model);
     Assert.IsTrue(controller.ModelState.IsValid, "model state is invalid");
     Assert.Contains(controller.TempData,
                     new KeyValuePair<string, object>
                         ("flash",
                          "Message successfully created"),
                     "Flash message is missing");
     mockService.VerifyAll();
 }
 public void create_should_add_message_to_repository()
 {
     //mock the repo
     var mockRepo = new Mock<IMessageRepository>();
     //set expectations
     mockRepo.Expect(r => r.Add(model)).Returns(1);
     var mockValidationRunner = new Mock<IValidationRunner>();
     var service = new InMemoryMessageService(mockRepo.Object,
                                              mockValidationRunner.Object);
     controller = new MessageController(service, null);
     var result = controller.Create(model);
     mockRepo.VerifyAll();
 }
 public void create_should_redirect_to_list_view_after_successful_save()
 {
     var mockService = new Mock<IMessageService>();
     mockService.Expect(s => s.Add(model)).Returns(1);
     controller = new MessageController(mockService.Object, null);
     var result = controller.Create(model);
     result.AssertRedirectToRouteResult("browse");
     mockService.VerifyAll();
 }