Ejemplo n.º 1
0
        public void Test_Redirect_Model_IsNotValid()
        {
            var mock       = new Mock <ITestService>();
            var controller = new TestDBController(mock.Object, null);

            controller.ModelState.AddModelError("Name", "Required");
            TestDB testDB = new TestDB();

            var result = controller.AddTestNotMap(testDB);

            var view = Assert.IsType <OkObjectResult>(result);

            Assert.Equal(testDB, view.Value);
        }
Ejemplo n.º 2
0
        public void Test_Can_AddModel()
        {
            var mock       = new Mock <ITestService>();
            var controller = new TestDBController(mock.Object, null);
            var newTest    = new TestDB()
            {
                Name    = "Lena",
                Surname = "Tselikina",
                Age     = 42
            };



            var result = controller.AddTestNotMap(newTest);

            mock.Verify(r => r.CreateTest(It.Is <TestDB>(s => s.Name == "Lena")), Times.Once());
            Assert.Equal("Lena", newTest.Name);
        }