public async Task DeleteNonExistingPurchaser() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository repository = new PurchaserRepository(dbContext); Purchaser purchaser = new Purchaser() { Id = 1, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; // act Purchaser result = await repository.DeletePurchaserForProfile(purchaser.ProfileId); // assert Assert.IsTrue(result == null); dbContext.Dispose(); }
public async Task AddPurchaserToDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository repository = new PurchaserRepository(dbContext); Purchaser purchaser = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; // act Purchaser result = await repository.AddPurchaser(purchaser); // assert Assert.IsTrue(result.Id > 0); dbContext.Dispose(); }
public async Task GetNonExistingPurchasersForCountryFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository countryRepository = new CountryRepository(dbContext); Country country = new Country() { Id = 0, ProfileId = 0, CountryName = "Name", CountryCode = "Code", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; PurchaserRepository repository = new PurchaserRepository(dbContext); await countryRepository.AddCountry(country); // act List <Purchaser> result = await repository.GetPurchasersForCountry(1); // assert Assert.IsTrue(result.Count == 0); dbContext.Dispose(); }
public async Task GetExistingPurchaserWithProfileFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository repository = new PurchaserRepository(dbContext); Purchaser purchaser = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; Purchaser addedPurchaser = await repository.AddPurchaser(purchaser); // act Purchaser result = await repository.GetPurchaserForProfile(addedPurchaser.ProfileId); // assert Assert.IsTrue(result == addedPurchaser); dbContext.Dispose(); }
public async Task UpdateExistingPurchaserInDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository repository = new PurchaserRepository(dbContext); Purchaser purchaser = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; Purchaser addedPurchaser = await repository.AddPurchaser(purchaser); addedPurchaser.Profile.Username = "******"; addedPurchaser.Profile.Password = "******"; // act Purchaser result = await repository.UpdatePurchaser(addedPurchaser); // assert Assert.IsTrue(result == addedPurchaser); dbContext.Dispose(); }
public async Task GetNonExistingPurchasersFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository repository = new PurchaserRepository(dbContext); // act List <Purchaser> result = (List <Purchaser>) await repository.GetPurchasers(); // assert Assert.IsTrue(result.Count == 0); dbContext.Dispose(); }
public async Task GetExistingPurchasersFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository repository = new PurchaserRepository(dbContext); Purchaser purchaser1 = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; Purchaser purchaser2 = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; Purchaser addedPurchaser1 = await repository.AddPurchaser(purchaser1); Purchaser addedPurchaser2 = await repository.AddPurchaser(purchaser2); // act List <Purchaser> result = (List <Purchaser>) await repository.GetPurchasers(); // assert Assert.IsTrue(result.Count == 2); Assert.IsTrue(result.Contains(addedPurchaser1)); Assert.IsTrue(result.Contains(addedPurchaser2)); dbContext.Dispose(); }
public PurchasersController(PurchaserRepository purchaserRepository) { _purchaserRepository = purchaserRepository; }
public async Task GetExistingArticlesForPurchaserFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); PurchaserRepository purchaserRepository = new PurchaserRepository(dbContext); Purchaser purchaser = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 0, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; ArticleRepository repository = new ArticleRepository(dbContext); Article article1 = new Article() { Id = 0, PurchaserId = 1, CountryId = 0, SupplierId = 0, ArticleInformationId = 0, InternalArticleInformationId = 0, VailedForCustomer = "Customer", DateCreated = DateTime.Now, ArticleInformationCompleted = 0, InternalArticalInformationCompleted = 0, ArticleState = 0, ErrorReported = 0, ErrorField = "Field", ErrorMessage = "Message", ErrorOwner = "Owner", ArticleInformation = new ArticleInformation(), InternalArticleInformation = new InternalArticleInformation() }; Article article2 = new Article() { Id = 0, PurchaserId = 1, CountryId = 0, SupplierId = 0, ArticleInformationId = 0, InternalArticleInformationId = 0, VailedForCustomer = "Customer", DateCreated = DateTime.Now, ArticleInformationCompleted = 0, InternalArticalInformationCompleted = 0, ArticleState = 0, ErrorReported = 0, ErrorField = "Field", ErrorMessage = "Message", ErrorOwner = "Owner", ArticleInformation = new ArticleInformation(), InternalArticleInformation = new InternalArticleInformation() }; await purchaserRepository.AddPurchaser(purchaser); Article addedArticle1 = await repository.AddArticle(article1); Article addedArticle2 = await repository.AddArticle(article2); // act List <Article> result = (List <Article>) await repository.GetArticlesForPurchaser(1); // assert Assert.IsTrue(result.Count == 2); Assert.IsTrue(result.Contains(addedArticle1)); Assert.IsTrue(result.Contains(addedArticle2)); dbContext.Dispose(); }