public void CanRemoveMake() { var repo = new MakeRepository(); Assert.AreEqual(3, repo.GetAll().Count); repo.Remove(1); Assert.AreEqual(2, repo.GetAll().Count); }
public void CanAddMake() { var repo = new MakeRepository(); Assert.AreEqual(3, repo.GetAll().Count); repo.Add(new Make() { MakeName = "Big" }); Assert.AreEqual(4, repo.GetAll().Count); }
public void MakeRepositoryGetAllTest() { //Arrange IncludeAllMappings.include(); var vMake = new VehicleMakeDomain() { Name = "MakeRepositoryGetAllTest", Abrv = "MakeRepositoryGetAllTest", VehicleMakeId = Guid.NewGuid(), VehicleModel = null }; var context = new VehicleContext(); var repository = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var testRepository = new MakeRepository(repository); int response; Task.Run(async() => { response = await testRepository.Add(vMake); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); //Act Task.Run(async() => { var result = await testRepository.GetAll(); //Assert Assert.IsNotNull(result); }).GetAwaiter().GetResult(); }
public async Task <IEnumerable <IVehicleMakeDomain> > ReadAll() { try { var response = await MakeRepository.GetAll(); return(response); } catch (Exception ex) { throw ex; } }
public void MakeRepositoryGetTest() { //Arrange IncludeAllMappings.include(); var vMake = new VehicleMakeDomain() { Name = "MakeRepositoryGetTest", Abrv = "MakeRepositoryGetTest", VehicleModel = null }; var context = new VehicleContext(); var repository = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var testRepository = new MakeRepository(repository); int response; Task.Run(async() => { response = await testRepository.Add(vMake); //Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); IEnumerable <IVehicleMakeDomain> getAll; IVehicleMakeDomain targetMake = null; Task.Run(async() => { getAll = await testRepository.GetAll(); //Assert Assert.IsNotNull(getAll); foreach (var item in getAll) { targetMake = item; } var result = await testRepository.Get(targetMake.VehicleMakeId); //Assert Assert.AreEqual(targetMake.VehicleMakeId, result.VehicleMakeId); }).GetAwaiter().GetResult(); }
public void ModelRepositoryGetTest() { //Arrange //Init repo IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var testRepository = new ModelRepository(repository); var makeRepository = new MakeRepository(repository); //Create maker var vMake = new VehicleMakeDomain() { Name = "ModelRepositoryGetTest", Abrv = "ModelRepositoryGetTest" }; Task.Run(async() => { var response = await makeRepository.Add(vMake); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); //Get maker IEnumerable <IVehicleMakeDomain> getAllMakers = null; IVehicleMakeDomain targetMaker = null; Task.Run(async() => { getAllMakers = await makeRepository.GetAll(); Assert.IsNotNull(getAllMakers); foreach (var item in getAllMakers) { targetMaker = item; } }).GetAwaiter().GetResult(); //Create model var vModel = new VehicleModelDomain() { Name = "ModelRepositoryGetTest", Abrv = "ModelRepositoryGetTest", VehicleMakeId = targetMaker.VehicleMakeId }; //Add model Task.Run(async() => { var response = await testRepository.Add(vModel); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); //Get model IEnumerable <IVehicleModelDomain> getAll; IVehicleModelDomain targetModel = null; Task.Run(async() => { getAll = await testRepository.GetAll(); Assert.IsNotNull(getAll); foreach (var item in getAll) { targetModel = item; } var result = await testRepository.Get(targetModel.VehicleModelId); //Assert Assert.AreEqual(targetModel.VehicleModelId, result.VehicleModelId); }).GetAwaiter().GetResult(); }
public List <Make> GetMake() { return(_makeRepository.GetAll().ToList <Make>()); }
public void CanGetAllMake() { var repo = new MakeRepository(); Assert.AreEqual(3, repo.GetAll().Count); }