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



            //Act
            offerController.Create(newOffer);
            controller.Create(newSeed);
            controller.DeleteConfirmed(newSeed.SeedId);
            var seedOutput = (controller.Index() as ViewResult).ViewData.Model as List <Seed>;


            //Assert
            CollectionAssert.DoesNotContain(seedOutput, newSeed);
            db.DeleteAll();
        }
Beispiel #2
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();
        }
Beispiel #3
0
        public void Mock_IndexContainsModelData_List()
        {
            // Arrange
            DbSetup();
            ViewResult indexView = new SeedsController(mock.Object).Index() as ViewResult;

            // Act
            var result = indexView.ViewData.Model;

            // Assert
            Assert.IsInstanceOfType(result, typeof(List <Seed>));
        }
Beispiel #4
0
        public void Mock_GetViewResultIndex_ActionResult() // Confirms route returns view
        {
            //Arrange
            DbSetup();
            SeedsController controller = new SeedsController(mock.Object);

            //Act
            var result = controller.Index();

            //Assert
            Assert.IsInstanceOfType(result, typeof(ActionResult));
        }
Beispiel #5
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));
        }
Beispiel #6
0
        public void TestDB_CreateSeed_Adds()
        {
            //Arrange
            OffersController offerController = new OffersController(dbOffers);
            SeedsController  controller      = new SeedsController(db);

            Offer newOffer = new Offer {
                OfferId = 1, Name = "HFBW"
            };
            Seed newSeed = new Seed {
                SeedId = 100, Name = "Amaranth", Amount = 40, Description = "A plant", OfferId = 1
            };

            //Act

            offerController.Create(newOffer);
            controller.Create(newSeed);
            var newList = (controller.Index() as ViewResult).ViewData.Model as List <Seed>;

            //Assert

            CollectionAssert.Contains(newList, newSeed);
            db.DeleteAll();
        }