Exemple #1
0
        public async System.Threading.Tasks.Task RegionEditEdits()
        {
            //Arrange
            Region regionTest = new Region()
            {
                RegionID = 100, RegionDescription = "Aici"
            };
            await _regionsControllerTest.Create(regionTest);

            db.Entry(regionTest).State = System.Data.Entity.EntityState.Added;

            var expectedRegion = db.Regions.Find(regionTest.RegionID);

            db.Dispose();
            regionTest.RegionDescription = "Acolo";
            db = new NorthwindDatabase();

            //Act
            await _regionsControllerTest.Edit(regionTest);

            db.Entry(regionTest).State = System.Data.Entity.EntityState.Modified;
            var actualRegion = db.Regions.Find(regionTest.RegionID);

            //Assert
            Assert.AreEqual(expectedRegion, actualRegion);


            var region = db.Regions.Where(r => (r.RegionDescription == "Aici") || (r.RegionDescription == "Acolo"));

            db.Regions.RemoveRange(region);
            db.SaveChanges();
        }