コード例 #1
0
ファイル: ResourceChangeTest.cs プロジェクト: dhach/backend
        public async Task Test_ChangePersonalInformation_NotPossible()
        {
            //Take the personal from the inserted offer and change attributes that cannot be updated
            Personal personal   = _offer.personals[0];
            var      idOriginal = personal.id;

            personal.id = 999999;

            //Try to update
            var changedRows = await _resourceStockUpdateService.ChangeInformationAsync(_token, personal);

            Assert.True(changedRows == 0);

            //The personal in the original manpower should still be findable
            Manpower queryManpower = _captainHookGenerator.GenerateQueryManpower();
            var      response      = await _resourceStockQueryService.QueryOffersAsync(queryManpower, "de")
                                     .ToListAsync();

            //Assert
            Assert.NotNull(response);
            Assert.NotEmpty(response);
            var personalFromQuery = response.First().resource;

            Assert.True(personalFromQuery.id == idOriginal);
        }
コード例 #2
0
        public void QueryManpower_BadInputs()
        {
            var manpower = _captainHookGenerator.GenerateQueryManpower();

            manpower.address.PostalCode = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForStockQuery(manpower));
        }
コード例 #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));
        }