public void QueryConsumable_BadInputs() { var consumable = _captainHookGenerator.GenerateQueryConsumable(); consumable.category = ""; Assert.Throws <ArgumentException>(() => _service.ValidateForStockQuery(consumable)); consumable = _captainHookGenerator.GenerateQueryConsumable(); consumable.address.Country = ""; Assert.Throws <ArgumentException>(() => _service.ValidateForStockQuery(consumable)); }
public async Task Test_ChangeConsumableInformation_NotPossible() { //Take the consumable from the inserted offer and change attributes that cannot be updated Consumable consumable = _offer.consumables[0]; var categoryOriginal = consumable.category; var idOriginal = consumable.id; consumable.category = "Doch was anderes"; consumable.id = 999999; //Try to update var changedRows = await _resourceStockUpdateService.ChangeInformationAsync(_token, consumable); Assert.True(changedRows == 0); //Generate the consumable for the query that should still be findable Consumable queryConsumable = _captainHookGenerator.GenerateQueryConsumable(); var response = await _resourceStockQueryService.QueryOffersAsync(queryConsumable, "de") .ToListAsync(); //Assert Assert.NotNull(response); Assert.NotEmpty(response); Consumable consumableFromQuery = response.First().resource; Assert.True(consumableFromQuery.category.Equals(categoryOriginal)); Assert.True(consumableFromQuery.id == idOriginal); }
public void QueryConsumable_BadInputs() { //Invalid category var consumable = _captainHookGenerator.GenerateQueryConsumable(); consumable.category = ""; Assert.Throws <ArgumentException>(() => _service.ValidateForDemandQuery(consumable)); //Country empty but postal code specified consumable = _captainHookGenerator.GenerateQueryConsumable(); consumable.address.Country = ""; Assert.Throws <ArgumentException>(() => _service.ValidateForDemandQuery(consumable)); //Negative kilometer consumable = _captainHookGenerator.GenerateQueryConsumable(); consumable.kilometer = -10; Assert.Throws <ArgumentException>(() => _service.ValidateForDemandQuery(consumable)); }
public async Task InsertOffer_QueryOfferElements_DeleteOffer() { //Insert the offer var offer = _captainHookGenerator.generateOffer(); var token = await _resourceStockUpdateService.InsertAsync(offer, "de"); Assert.True(token.Length == 30); //Query the link var entity = await _resourceStockQueryService.QueryLinkAsync(token); Assert.Equal(offer.provider.name, entity.provider.name); //Now query the elements. If it is not empty we received the element back //Get device var queryDevice = _captainHookGenerator.GenerateQueryDevice(); var resultDevices = await _resourceStockQueryService.QueryOffersAsync(queryDevice, "de") .ToListAsync(); Assert.NotNull(resultDevices); Assert.NotEmpty(resultDevices); var deviceFromQuery = resultDevices.First().resource; var deviceOriginal = offer.devices.First(); Console.Out.WriteLine(deviceFromQuery); Console.Out.WriteLine(deviceOriginal); Assert.Equal(deviceOriginal, deviceFromQuery); //check the provider var providerFromQuery = resultDevices.First().provider; var providerOriginal = offer.provider; Console.Out.WriteLine(providerFromQuery); Console.Out.WriteLine(providerOriginal); // ---- HOTFIX // Vorerst sollen keine persönliche Daten veröffentlicht werden. // Assert.True(providerOriginal.Equals(providerFromQuery)); //Get consumable var queryConsumable = _captainHookGenerator.GenerateQueryConsumable(); var resultConsumables = await _resourceStockQueryService.QueryOffersAsync(queryConsumable, "de") .ToListAsync(); Assert.NotNull(resultConsumables); Assert.NotEmpty(resultDevices); var consumableFromQuery = resultConsumables.First().resource; var consumableOriginal = offer.consumables.First(); Console.Out.WriteLine(consumableFromQuery); Console.Out.WriteLine(consumableOriginal); Assert.Equal(consumableOriginal, consumableFromQuery); //Get personal var manpowerQuery = _captainHookGenerator.GenerateQueryManpower(); var resultPersonal = await _resourceStockQueryService.QueryOffersAsync(manpowerQuery, "de") .ToListAsync(); Assert.NotNull(resultPersonal); Assert.NotEmpty(resultPersonal); var personal = resultPersonal.First(); Assert.Equal(offer.personals.First().area, personal.resource.area); Assert.Equal(offer.personals.First().qualification, personal.resource.qualification); //Delete the offer and check if it worked var exception = await Record.ExceptionAsync(() => _resourceStockUpdateService.DeleteAsync(token)); Assert.Null(exception); //Offer should be not available anymore await Assert.ThrowsAsync <DataNotFoundException>(async() => await _resourceStockQueryService.QueryLinkAsync(token)); }