コード例 #1
0
        public void TestDB_SeedEdit_Updates()
        {
            //Arrange
            OffersController offerController = new OffersController(dbOffers);
            SeedsController  controller      = new SeedsController(db);
            Offer            newOffer        = new Offer {
                OfferId = 10, Name = "HFBW"
            };
            Seed newSeed = new Seed {
                SeedId = 10, Name = "Amaranht", Amount = 40, Description = "A plant", OfferId = 10
            };



            //Act
            offerController.Create(newOffer);
            controller.Create(newSeed);

            newSeed.Name = "Amaranth";
            controller.Edit(newSeed);
            var seedOutput = (controller.Details(10) as ViewResult).ViewData.Model as Seed;

            //Assert
            Assert.AreEqual(seedOutput.Name, "Amaranth");
            db.DeleteAll();
        }
コード例 #2
0
        public void Mock_GetDetails_ReturnsView()
        {
            // Arrange
            Seed testSeed = new Seed();

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

            // Act
            var resultView = controller.Details(testSeed.SeedId) as ViewResult;
            var model      = resultView.ViewData.Model as Seed;

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