コード例 #1
0
ファイル: ResourceChangeTest.cs プロジェクト: dhach/backend
        public async Task InitializeAsync()
        {
            var offer = _captainHookGenerator.generateOffer();
            var token = await _resourceStockUpdateService.InsertAsync(offer, "de");

            offer = await _resourceStockQueryService.QueryLinkAsync(token);

            (_offer, _token) = (offer, token);
        }
コード例 #2
0
        public void InsertOffer_BadInputs()
        {
            var offer = _captainHookGenerator.generateOffer();

            offer.provider.name = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForStockInsertion(offer));

            offer = _captainHookGenerator.generateOffer();
            offer.consumables.First().unit = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForStockInsertion(offer));

            offer = _captainHookGenerator.generateOffer();
            offer.devices.First().category = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForStockInsertion(offer));

            offer = _captainHookGenerator.generateOffer();
            offer.personals.First().qualification = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForStockInsertion(offer));

            offer = _captainHookGenerator.generateOffer();
            offer.personals.First().area = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForStockInsertion(offer));
        }
コード例 #3
0
        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));
        }