예제 #1
0
        public void Valid_DM_Code_Create()
        {
            //Arrange
            DM_Code c = new DM_Code() { Name = "test1" };

            //Act
            var result = (RedirectToRouteResult)objController.Create(c);

            //Assert
            _dmCodeServiceMock.Verify(m => m.Create(c), Times.Once);
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
예제 #2
0
        public void Invalid_DM_Code_Create()
        {
            // Arrange
            DM_Code c = new DM_Code() { Name = "" };
            objController.ModelState.AddModelError("Error", "Something went wrong");

            //Act
            var result = (ViewResult)objController.Create(c);

            //Assert
            _dmCodeServiceMock.Verify(m => m.Create(c), Times.Never);
            Assert.AreEqual("", result.ViewName);
        }