コード例 #1
0
        public void DB_CreatesNewProperties_Collection()
        {
            // Arrange
            PropertiesController controller   = new PropertiesController(db);
            Property             testProperty = new Property();

            testProperty.Name        = "TestDb Property";
            testProperty.Cost        = 400;
            testProperty.Description = "Big";

            // Act
            controller.Create(testProperty);
            var collection = (controller.Index() as ViewResult).ViewData.Model as List <Property>;

            // Assert
            CollectionAssert.Contains(collection, testProperty);
        }
コード例 #2
0
        public void Mock_PostViewResultCreate_ViewResult()
        {
            // Arrange
            Property testProperty = new Property
            {
                PropertyId = 4,
                Name       = "Drawer"
            };

            DbSetup();
            PropertiesController controller = new PropertiesController(mock.Object);

            // Act
            var resultView = controller.Create(testProperty) as ViewResult;


            // Assert
            Assert.IsInstanceOfType(resultView, typeof(ViewResult));
        }