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 TestDB_CreateOffer_Adds()
        {
            OffersController controller = new OffersController(db);
            Offer            newOffer   = new Offer {
                OfferId = 100, Name = "HFBW"
            };

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

            CollectionAssert.Contains(newList, newOffer);
            db.DeleteAll();
        }
Beispiel #4
0
        public void TestDB_OfferEdit_Updates()
        {
            //Arrange
            OffersController controller = new OffersController(db);
            Offer            newOffer   = new Offer {
                OfferId = 1, Name = "HFBW"
            };



            //Act
            controller.Create(newOffer);
            newOffer.Name = "Human Flesh Body World";
            controller.Edit(newOffer);
            var offerOutput = (controller.Details(1) as ViewResult).ViewData.Model as Offer;

            Assert.AreEqual(offerOutput.Name, "Human Flesh Body World");
            db.DeleteAll();
        }
Beispiel #5
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();
        }