public void Test_ChangeProviderInformation_BadInputs()
        {
            Provider provider = _captainHookGenerator.GenerateProvider();

            provider.name = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForChangeInformation(_dummyToken, provider));

            provider = _captainHookGenerator.GenerateProvider();
            provider.organisation = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForChangeInformation(_dummyToken, provider));

            //provider = _captainHookGenerator.GenerateProvider();
            //provider.phone = "";
            //Assert.Throws<ArgumentException>(() => _service.validateForChangeInformation(_dummyToken, provider));

            provider = _captainHookGenerator.GenerateProvider();
            provider.address.PostalCode = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForChangeInformation(_dummyToken, provider));

            provider = _captainHookGenerator.GenerateProvider();
            provider.address.Country = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForChangeInformation(_dummyToken, provider));

            provider      = _captainHookGenerator.GenerateProvider();
            provider.mail = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForChangeInformation(_dummyToken, provider));
        }
Пример #2
0
        public async Task Test_ChangeProviderInformation_Possible()
        {
            //Create a provider and change attributes
            Provider provider = _captainHookGenerator.GenerateProvider();

            provider.name               = "Peter Pan";
            provider.phone              = "987766";
            provider.organisation       = "Never Grow Up Kids";
            provider.address.PostalCode = "88888";
            provider.address.Country    = "Atlantis";

            //Update
            var changedRows = await _resourceStockUpdateService.ChangeInformationAsync(_token, provider);

            Assert.True(changedRows == 2);

            //We take a the token to get the offer with the updated provider
            var response = await _resourceStockQueryService.QueryLinkAsync(_token);

            //Assert
            Assert.NotNull(response);
            Provider providerFromOffer = response.provider;

            Console.Out.WriteLine(providerFromOffer);
            Console.Out.WriteLine(provider);
            Assert.Equal(provider, providerFromOffer);
        }
Пример #3
0
        public void InsertDemand_BadInputs()
        {
            // Missing Email
            Demand demand = _captainHookGenerator.GenerateDemand();

            demand.provider.mail = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForDemandInsertion(demand));

            // Missing resources
            Demand demand2 = new Demand()
            {
                provider = _captainHookGenerator.GenerateProvider()
            };

            Assert.Throws <ArgumentException>(() => _service.ValidateForDemandInsertion(demand2));

            // Wrong device
            Demand demand3 = _captainHookGenerator.GenerateDemand();

            demand3.devices[0].category = "";
            Assert.Throws <ArgumentException>(() => _service.ValidateForDemandInsertion(demand3));

            // Wrong consumable
            Demand demand4 = _captainHookGenerator.GenerateDemand();

            demand4.consumables[0].amount = 0;
            Assert.Throws <ArgumentException>(() => _service.ValidateForDemandInsertion(demand4));
        }