public void MakeServiceReadTest() { //Arange IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var makeRepository = new MakeRepository(repository); var modelRepository = new ModelRepository(repository); var vMake = new VehicleMakeDomain() { Name = "MakeServiceReadTest", Abrv = "MakeServiceReadTest", VehicleModel = null }; var testService = new MakeService(makeRepository, modelRepository); IEnumerable <IVehicleMakeDomain> readAll = null; IVehicleMakeDomain targetItem = null; Task.Run(async() => { readAll = await testService.ReadAll(); Assert.IsNotNull(readAll); targetItem = readAll.LastOrDefault(); }).GetAwaiter().GetResult(); Task.Run(async() => { //Act var result = await testService.Read(targetItem.VehicleMakeId); //Assert Assert.AreEqual(targetItem.VehicleMakeId, result.VehicleMakeId); }).GetAwaiter().GetResult(); }
public void MakeControllerGetAllTest() { //Arange IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var makeRepository = new MakeRepository(repository); var modelRepository = new ModelRepository(repository); var makeService = new MakeService(makeRepository, modelRepository); var testController = new MakeController(makeService); testController.Request = new HttpRequestMessage(); testController.Configuration = new HttpConfiguration(); //Add make var vMake = new VehicleMakeView() { Name = "MakeControllerGetAllTest", Abrv = "MakeControllerGetAllTest" }; Task.Run(async() => { var response = await testController.Add(vMake); Assert.IsNotNull(response); }).GetAwaiter().GetResult(); Task.Run(async() => { //Act var result = await testController.GetAll(); //Assert Assert.IsNotNull(result); }).GetAwaiter().GetResult(); }
public void ModelServiceReadAllTest() { //Arange IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var makeRepository = new MakeRepository(repository); var modelRepository = new ModelRepository(repository); var makeService = new MakeService(makeRepository, modelRepository); var testService = new ModelService(modelRepository); //Add make var vMake = new VehicleMakeDomain() { Name = "ModelServiceReadAllTest", Abrv = "ModelServiceReadAllTest", VehicleModel = null }; Task.Run(async() => { var response = await makeService.Add(vMake); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); IVehicleMakeDomain targetMake = null; //Get make Task.Run(async() => { var response = await makeService.ReadAll(); Assert.IsNotNull(response); targetMake = response.LastOrDefault(); }).GetAwaiter().GetResult(); //Create model var vModel = new VehicleModelDomain() { Name = "ModelServiceReadAllTest", Abrv = "ModelServiceReadAllTest", VehicleMakeId = targetMake.VehicleMakeId }; //Add model Task.Run(async() => { var response = await testService.Add(vModel); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); Task.Run(async() => { //Act var result = await testService.ReadAll(); //Assert Assert.IsNotNull(result); }).GetAwaiter().GetResult(); }
public void MakeControllerUpdateTest() { //Arange IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var makeRepository = new MakeRepository(repository); var modelRepository = new ModelRepository(repository); var makeService = new MakeService(makeRepository, modelRepository); var testController = new MakeController(makeService); testController.Request = new HttpRequestMessage(); testController.Configuration = new HttpConfiguration(); //Add make var vMake = new VehicleMakeView() { Name = "MakeControllerUpdateTest", Abrv = "MakeControllerUpdateTest" }; Task.Run(async() => { var response = await testController.Add(vMake); Assert.IsNotNull(response); }).GetAwaiter().GetResult(); //Get make VehicleMakeView targetItem = null; JavaScriptSerializer JSS = new JavaScriptSerializer(); Task.Run(async() => { var response = await testController.GetAll(); Assert.IsNotNull(response); IEnumerable <VehicleMakeView> obj = JSS.Deserialize <IEnumerable <VehicleMakeView> >(response.Content.ReadAsStringAsync().Result); targetItem = obj.LastOrDefault(); }).GetAwaiter().GetResult(); targetItem.Name = "MakeControllerUpdateTestTested"; Task.Run(async() => { //Act var response = await testController.Update(targetItem); //Assert int obj = JSS.Deserialize <int>(response.Content.ReadAsStringAsync().Result); Assert.AreEqual(1, obj); }).GetAwaiter().GetResult(); }
public void MakeServiceReadAllTest() { //Arange IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var makeRepository = new MakeRepository(repository); var modelRepository = new ModelRepository(repository); var testService = new MakeService(makeRepository, modelRepository); Task.Run(async() => { //Act var result = await testService.ReadAll(); //Assert Assert.IsNotNull(result); }).GetAwaiter().GetResult(); }
public void MakeServiceAddTest() { //Arange IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var makeRepository = new MakeRepository(repository); var modelRepository = new ModelRepository(repository); var vMake = new VehicleMakeDomain() { Name = "MakeRepositoryAddTest", Abrv = "MakeRepositoryAddTest", VehicleModel = null }; var testService = new MakeService(makeRepository, modelRepository); Task.Run(async() => { //Act var result = await testService.Add(vMake); //Assert Assert.AreEqual(1, result); }).GetAwaiter().GetResult(); }