public void Insert_Repos_SomeReposCountReturned()
        {
            //arrange
            var testContext       = CreateContextWithTestData();
            var repo              = new FakeGenericRepository(testContext);
            List <CarModels> list = new List <CarModels>
            {
                new CarModels {
                    CarModelID = 4, ManufactorID = 5, Name = "Four"
                },
                new CarModels {
                    CarModelID = 5, ManufactorID = 6, Name = "Five"
                },
                new CarModels {
                    CarModelID = 6, ManufactorID = 7, Name = "Six"
                }
            };
            var actualCount = repo.Get().Count();

            //act
            repo.Insert(list);
            var expectedCount = repo.Get().Count();
            var expected      = repo.GetByParam(x => x.CarModelID == 6);

            //asert
            Assert.AreEqual(actualCount + 3, expectedCount);
            Assert.AreEqual(list[2].Name, expected.Name);
        }
        public void Delete_Repo_OneRepoMinusReturned()
        {
            //arrange
            var testContext = CreateContextWithTestData();
            var repo        = new FakeGenericRepository(testContext);
            int deletedID   = 2;

            //act
            var actual = repo.Get(x => x.CarModelID == deletedID);

            repo.Delete(deletedID);
            var expected = repo.Get(x => x.CarModelID == deletedID);

            //asert
            Assert.AreNotEqual(expected, actual);
        }
        public void Delete_Repos_SomeReposDeleteReturned()
        {
            //arrange
            var testContext       = CreateContextWithTestData();
            var repo              = new FakeGenericRepository(testContext);
            List <CarModels> list = new List <CarModels>
            {
                new CarModels {
                    CarModelID = 3, ManufactorID = 4, Name = "Three"
                }
            };

            //act
            var actual = repo.Get(x => x.CarModelID == 3);

            repo.Delete(list);
            var expected = repo.Get(x => x.CarModelID == 3);

            //asert
            Assert.AreNotEqual(expected, actual);
        }
        public void Update_Repos_SomeReposCountReturned()
        {
            //arrange
            var    testContext  = CreateContextWithTestData();
            var    repo         = new FakeGenericRepository(testContext);
            string expectedName = "change";
            var    car          = repo.Get(x => x.CarModelID >= 2);

            foreach (var c in car)
            {
                c.Name = expectedName;
            }

            //act
            repo.Update(car);
            testContext.SaveChanges();
            var newCar = repo.Get(x => x.CarModelID >= 2);

            //asert
            Assert.AreNotEqual(car, newCar);
        }
        public void Insert_Repo_RepoPlusOneReturned()
        {
            //arrange
            var testContext = CreateContextWithTestData();
            var repo        = new FakeGenericRepository(testContext);
            var model       = new CarModels
            {
                Name         = "four",
                CarModelID   = 4,
                ManufactorID = 5
            };
            var actualCount = repo.Get().Count();

            //act
            repo.Insert(model);
            var expectedCount  = repo.Get().Count();
            var expectedRecord = repo.GetByParam(x => x.CarModelID == 4);

            //asert
            Assert.AreEqual(actualCount + 1, expectedCount);
            Assert.AreEqual(expectedRecord.Name, model.Name);
        }
        public void Get_Repo_ReposelectionReturned()
        {
            //arrange
            var testContext = CreateContextWithTestData();
            var repo        = new FakeGenericRepository(testContext);
            var actualCount = 3;
            //act
            var entity        = repo.Get();
            var expectedCount = entity.Count();

            //asert
            Assert.AreNotEqual(entity, null);
            Assert.AreEqual(actualCount, expectedCount);
        }