public async Task Get_NoCondition() { var newCar1 = GetNewCar(Color.AntiqueWhite, 2020); var carService = await DependenciesTestHelper.GetCarServiceWithCars(nameof(CarServiceTest) + nameof(Get_NoCondition), newCar1); var response = await carService.Get(1).ConfigureAwait(false); CarsEqual(response, newCar1).Should().BeTrue(""); }
public async Task Get_NoCondition() { var newMaker1 = GetNewMaker("name 1"); var makerService = await DependenciesTestHelper.GetMakerServiceWithMakers(nameof(MakerServiceTest) + nameof(Get_NoCondition), newMaker1); var response = await makerService.Get(1).ConfigureAwait(false); response.Should().BeEquivalentTo(newMaker1, options => options.Including(maker => maker.Name)); }
public async Task GetAll_NoCondition() { var newCar1 = GetNewCar(Color.AntiqueWhite, 2020); var newCar2 = GetNewCar(Color.Aqua, 1999); var carService = await DependenciesTestHelper.GetCarServiceWithCars(nameof(CarServiceTest) + nameof(GetAll_NoCondition), newCar1, newCar2); var response = await carService.GetAll().ConfigureAwait(false); response.Should().OnlyContain(car => CarsEqual(car, newCar1) || CarsEqual(car, newCar2)); }
public async Task GetAll_NoCondition() { var newMaker1 = GetNewMaker("name 1"); var newMaker2 = GetNewMaker("name 2"); var makerService = await DependenciesTestHelper.GetMakerServiceWithMakers(nameof(MakerServiceTest) + nameof(GetAll_NoCondition), newMaker1, newMaker2); var response = await makerService.GetAll().ConfigureAwait(false); response.Should().OnlyContain(maker => MakersEqual(maker, newMaker1) || MakersEqual(maker, newMaker2)); }
public async Task Get_NoCondition() { var newModel1 = GetNewModel("name 1"); var modelService = await DependenciesTestHelper.GetModelServiceWithModels(GetName(nameof(Get_NoCondition)), newModel1); var response = await modelService.Get(1).ConfigureAwait(false); response.Should().BeEquivalentTo(newModel1, options => options.Including(model => model.Name).Including(model => model.MakerId)); }
public async Task GetAll_NoCondition() { var newModel1 = GetNewModel("name 1"); var newModel2 = GetNewModel("name 2"); var modelService = await DependenciesTestHelper.GetModelServiceWithModels(GetName(nameof(GetAll_NoCondition)), newModel1, newModel2); var response = await modelService.GetAll().ConfigureAwait(false); response.Should().OnlyContain(model => ModelsEqual(model, newModel1) || ModelsEqual(model, newModel2)); }
public async Task Remove_NoCondition() { var newMaker1 = GetNewMaker("name 1"); var makerService = await DependenciesTestHelper.GetMakerServiceWithMakers(nameof(MakerServiceTest) + nameof(Remove_NoCondition), newMaker1); var removed = await makerService.Remove(1).ConfigureAwait(false); var removedMaker = await makerService.Get(1).ConfigureAwait(false); removed.Should().BeTrue("Maker was not removed in the DB"); removedMaker.Should().BeNull(); }
public async Task Remove_NoCondition() { var newModel1 = GetNewModel("name 1"); var modelService = await DependenciesTestHelper.GetModelServiceWithModels(GetName(nameof(Remove_NoCondition)), newModel1); var removed = await modelService.Remove(1).ConfigureAwait(false); var removedModel = await modelService.Get(1).ConfigureAwait(false); removed.Should().BeTrue("Model was not removed in the DB"); removedModel.Should().BeNull(); }
public async Task Add_NoCondition() { var newMaker1 = GetNewApiMaker("name 1"); var makerService = await DependenciesTestHelper.GetMakerServiceWithMakers(nameof(MakerServiceTest) + nameof(Add_NoCondition)); var added = await makerService.Add(newMaker1).ConfigureAwait(false); var newMaker = await makerService.Get(1).ConfigureAwait(false); added.Should().BeTrue("Maker was not added to the DB"); newMaker.Should().BeEquivalentTo(newMaker1, options => options.Including(maker => maker.Name), "Added maker was not found in the DB"); }
public async Task Add_NoCondition() { var newCar1 = GetNewApiCar(Color.AntiqueWhite, 1, 2020); var carService = await DependenciesTestHelper.GetCarService(nameof(CarServiceTest) + nameof(Add_NoCondition)); var added = await carService.Add(newCar1).ConfigureAwait(false); var newCar = await carService.Get(1).ConfigureAwait(false); added.Should().BeTrue("Car was not added to the DB"); newCar.Should().BeEquivalentTo(newCar1, options => options.Including(car => car.Colour).Including(car => car.ModelId).Including(car => car.Year), "Added car was not found in the DB"); }
public async Task Remove_NoCondition() { var newCar1 = GetNewCar(Color.AntiqueWhite, 2020); var carService = await DependenciesTestHelper.GetCarServiceWithCars(nameof(CarServiceTest) + nameof(Remove_NoCondition), newCar1); var newCar = await carService.Get(1).ConfigureAwait(false); var removed = await carService.Remove(1).ConfigureAwait(false); var removedCar = await carService.Get(1).ConfigureAwait(false); newCar.Should().NotBeNull("Car was not added... Problem with test"); removed.Should().BeTrue("Car was not removed in the DB"); removedCar.Should().BeNull(); }
public async Task Update_NoCondition() { var newCar1 = GetNewCar(Color.AntiqueWhite, 2020); var carService = await DependenciesTestHelper.GetCarServiceWithCars(nameof(CarServiceTest) + nameof(Update_NoCondition), newCar1); var newCar = await carService.Get(1).ConfigureAwait(false); newCar.Year = 22222; var updated = await carService.Update(newCar).ConfigureAwait(false); var modifiedCar = await carService.Get(1).ConfigureAwait(false); updated.Should().BeTrue("Car was not updated in the DB"); modifiedCar.Should().BeEquivalentTo(newCar, options => options.IncludingProperties()); }
public async Task Add_NoCondition() { var carsContext = await DependenciesTestHelper.GetInMemoryCarsContext(GetName(nameof(Add_NoCondition))); var expectedRelatedWords = new List <string> { "related", "words" }; var relatedWordsService = new Mock <IRelatedWordsService>(); relatedWordsService.Setup(p => p.GetRelatedWords(It.IsAny <string>())) .ReturnsAsync(() => expectedRelatedWords); var newModel1 = GetNewApiModel("name 1", 1); var modelService = await DependenciesTestHelper.GetModelServiceWithMakers(carsContext, relatedWordsService.Object, new Maker { Name = "Maker Name" }); var added = await modelService.Add(newModel1).ConfigureAwait(false); var newModel = await modelService.Get(1).ConfigureAwait(false); added.Should().BeTrue("Model was not added to the DB"); newModel.Should().BeEquivalentTo(newModel1, options => options.Including(model => model.Name).Including(model => model.MakerId), "Added model was not found in the DB"); var carRepository = await DependenciesTestHelper.GetInMemoryCarRepository(carsContext); var carAdded = await carRepository.AddCar(new Car { ModelId = 1, Colour = Color.Aqua, Year = 1999 }); var newCar = await modelService.Get(1).ConfigureAwait(false); carAdded.Should().BeTrue("Car was not added with this model to the DB"); newCar.Should().NotBeNull("Car was not found in the DB"); var expectedRelatedWordsString = expectedRelatedWords.Aggregate((p1, p2) => p1 + ", " + p2); newCar.RelatedWords.Should().Be(expectedRelatedWordsString); }