Exemplo n.º 1
0
 public void When_Create_Then_Persits_In_Database()
 {
     //Arrange
     var application = new Application()
     {
         Id = 2,
         Name = "Test Application"
     };
     //Act
     var result = controller.Create(application) as RedirectToRouteResult;
     //Assert
     uowMock.Verify(u => u.Repository<Application>().Insert(application), Times.Once());
     //Assert.AreEqual("Index", result.RouteValues["action"]);
 }
Exemplo n.º 2
0
        public void When_Create_With_Invalid_Model_Then_Do_Not_Persit_In_Database()
        {
            //Arrange
            var application = new Application();
            controller.ModelState.AddModelError("key", "error");
            //Act
            var result = controller.Create(application) as ViewResult;
            //Assert
            uowMock.Verify(u => u.Repository<Application>().Insert(application), Times.Never());

            var model = result.ViewData.Model as Application;
            Assert.AreEqual(application, model);

            Assert.AreEqual("Create", result.ViewName);
        }