Beispiel #1
0
        public async Task DeletePurchaserForProfileDeletesThePurchaserIfItExists()
        {
            // arrange
            PurchaserService purchaserService = new PurchaserService(_client);
            CountryService   countryService   = new CountryService(_client);

            Purchaser purchaser = new Purchaser()
            {
                Id        = 0,
                ProfileId = 0,
                CountryId = 1,
                Profile   = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };

            Country country = new Country()
            {
                Id          = 0,
                ProfileId   = 0,
                CountryName = "Name",
                CountryCode = "Code",
                Profile     = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 0
                }
            };

            Country createdCountry = await countryService.CreateCountry(country);

            Purchaser createdPurchaser = await purchaserService.CreatePurchaser(purchaser);

            await purchaserService.DeletePurchaserForProfile(createdPurchaser.ProfileId);

            // act
            Purchaser expected = new Purchaser();
            Purchaser actual   = await purchaserService.GetPurchaser(createdPurchaser.ProfileId);

            // assert
            CollectionAssert.AreEquivalent(expected.Articles, actual.Articles);
            Assert.IsTrue(expected.Id == actual.Id);
            Assert.IsTrue(expected.CountryId == actual.CountryId);
            Assert.IsTrue(expected.ProfileId == actual.ProfileId);

            await countryService.DeleteCountry(createdCountry.Id);
        }
Beispiel #2
0
        public async Task GetPurchaserReturnsNewPurchaserIfItDoesNotExist()
        {
            // arrange
            PurchaserService purchaserService = new PurchaserService(_client);
            Purchaser        expected         = new Purchaser();

            // act
            Purchaser actual = await purchaserService.GetPurchaser(1);

            List <Purchaser> list = await purchaserService.GetPurchasers();

            // assert
            Assert.IsTrue(expected.Country == actual.Country);
            Assert.IsTrue(expected.Id == actual.Id);
            CollectionAssert.AreEquivalent(expected.Articles, actual.Articles);
            Assert.IsTrue(expected.CountryId == actual.CountryId);
            Assert.IsTrue(expected.ProfileId == actual.ProfileId);
        }
Beispiel #3
0
        public async Task UpdatePurchaserUpdatesExistingPurchaser()
        {
            // arrange
            PurchaserService purchaserService = new PurchaserService(_client);
            Purchaser        purchaser        = new Purchaser()
            {
                Id        = 0,
                ProfileId = 0,
                CountryId = 0,
                Profile   = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };

            Purchaser expected = await purchaserService.CreatePurchaser(purchaser);

            expected.Profile.Password = "******";

            await purchaserService.UpdatePurchaser(expected.Id, expected);

            // act
            Purchaser actual = await purchaserService.GetPurchaser(expected.Id);

            // assert
            Assert.IsTrue(expected.Country == actual.Country);
            Assert.IsTrue(expected.Id == actual.Id);
            CollectionAssert.AreEquivalent(expected.Articles, actual.Articles);
            Assert.IsTrue(expected.CountryId == actual.CountryId);
            Assert.IsTrue(expected.Id == actual.Id);
            Assert.IsTrue(expected.Profile.Id == actual.Profile.Id);
            Assert.IsTrue(expected.Profile.Password == actual.Profile.Password);
            CollectionAssert.AreEquivalent(expected.Profile.Purchasers, actual.Profile.Purchasers);
            Assert.IsTrue(expected.Profile.Username == actual.Profile.Username);
            CollectionAssert.AreEquivalent(expected.Profile.Purchasers, actual.Profile.Purchasers);
            Assert.IsTrue(expected.Profile.Usertype == actual.Profile.Usertype);
            CollectionAssert.AreEquivalent(expected.Profile.Countries, actual.Profile.Countries);
            Assert.IsTrue(expected.ProfileId == actual.ProfileId);

            await purchaserService.DeletePurchaserForProfile(expected.ProfileId);
        }