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 UpdateExistingCountryInDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); Country country = new Country() { Id = 0, ProfileId = 0, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; Country addedCountry = await repository.AddCountry(country); addedCountry.CountryName = "Denmark"; addedCountry.CountryCode = "DK"; addedCountry.Profile.Username = "******"; addedCountry.Profile.Password = "******"; // act Country result = await repository.UpdateCountry(addedCountry); // assert Assert.IsTrue(result == addedCountry); dbContext.Dispose(); }
public async Task GetExistingSupplierWithProfileFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); SupplierRepository repository = new SupplierRepository(dbContext); Supplier supplier = new Supplier() { Id = 0, ProfileId = 0, CompanyName = "Name", CompanyLocation = "Location", FreightResponsibility = "EXW", PalletExchange = 1, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; Supplier addedSupplier = await repository.AddSupplier(supplier); // act Supplier result = await repository.GetSupplierWithProfile(addedSupplier.ProfileId); // assert Assert.IsTrue(result == addedSupplier); dbContext.Dispose(); }
public async Task DeleteNonExistingCountry() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); Country country = new Country() { Id = 0, ProfileId = 0, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; // act Country result = await repository.DeleteCountryAsync(country.Id); // assert Assert.IsTrue(result == null); dbContext.Dispose(); }
public async Task GetNonExistingCountryWithEverythingFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); Country country = new Country() { Id = 1, ProfileId = 1, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 1, Username = "******", Password = "******", Usertype = 0 } }; // act Country result = await repository.GetCountryEverything(country.Id); // assert Assert.IsTrue(result == default); dbContext.Dispose(); }
public async Task GetExistingCountryWithNameFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); Country country = new Country() { Id = 1, ProfileId = 1, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 1, Username = "******", Password = "******", Usertype = 0 } }; Country addedCountry = await repository.AddCountry(country); // act Country result = await repository.GetCountryWithName(addedCountry.CountryName); // assert Assert.IsTrue(result == addedCountry); dbContext.Dispose(); }
public async Task DeleteNonExistingSupplier() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); SupplierRepository repository = new SupplierRepository(dbContext); Supplier supplier = new Supplier() { Id = 1, ProfileId = 0, CompanyName = "Name", CompanyLocation = "Location", FreightResponsibility = "EXW", PalletExchange = 1, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; // act Supplier result = await repository.DeleteSupplierAsync(supplier.Id); // assert Assert.IsTrue(result == null); dbContext.Dispose(); }
public async Task DeleteNonExistingArticle() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); ArticleRepository repository = new ArticleRepository(dbContext); Article article = new Article() { Id = 1, PurchaserId = 0, CountryId = 0, SupplierId = 0, ArticleInformationId = 1, InternalArticleInformationId = 1, VailedForCustomer = "Customer", DateCreated = DateTime.Now, ArticleInformationCompleted = 0, InternalArticalInformationCompleted = 0, ArticleState = 0, ErrorReported = 0, ErrorField = "Field", ErrorMessage = "Message", ErrorOwner = "Owner" }; // act Article result = await repository.DeleteArticleAsync(article.Id); // assert Assert.IsTrue(result == null); dbContext.Dispose(); }
public async Task AddCountryToDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); Country country = new Country() { Id = 0, ProfileId = 0, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; // act Country result = await repository.AddCountry(country); // assert Assert.IsTrue(result.Id > 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 GetExistingArticleWithInformationFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); ArticleRepository repository = new ArticleRepository(dbContext); Article article = new Article() { Id = 0, PurchaserId = 0, 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 addedArticle = await repository.AddArticle(article); // act Article result = await repository.GetArticleWithInformation(addedArticle.ArticleInformationId); // assert Assert.IsTrue(result == addedArticle); 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 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 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(); }
private HAVIdatabaseContext CreateDbContext() { var options = new DbContextOptionsBuilder <HAVIdatabaseContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString("N")).Options; var dbContext = new HAVIdatabaseContext(options); return(dbContext); }
public ZArticleTest() { var webHostBuilder = new WebHostBuilder() .UseEnvironment("Testing") .UseStartup <Startup>(); var server = new TestServer(webHostBuilder); _context = server.Host.Services.GetService(typeof(HAVIdatabaseContext)) as HAVIdatabaseContext; _client = server.CreateClient(); }
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 GetNonExistingArticleWithArticleInformationFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); ArticleRepository repository = new ArticleRepository(dbContext); // act Article result = await repository.GetArticleWithInformation(1); // assert Assert.IsTrue(result == default); dbContext.Dispose(); }
public async Task GetNonExistingArticlesForPurchaserFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); ArticleRepository repository = new ArticleRepository(dbContext); // act List <Article> result = (List <Article>) await repository.GetArticlesForPurchaser(1); // assert Assert.IsTrue(result.Count == 0); dbContext.Dispose(); }
public async Task GetNonExistingCountriesFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); // act List <Country> result = (List <Country>) await repository.GetCountries(); // assert Assert.IsTrue(result.Count == 0); dbContext.Dispose(); }
public async Task GetExistingCountriesFromDatabaseTest() { // arrange HAVIdatabaseContext dbContext = CreateDbContext(); CountryRepository repository = new CountryRepository(dbContext); Country country1 = new Country() { Id = 0, ProfileId = 0, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; Country country2 = new Country() { Id = 0, ProfileId = 0, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; Country addedCountry1 = await repository.AddCountry(country1); Country addedCountry2 = await repository.AddCountry(country2); // act List <Country> result = (List <Country>) await repository.GetCountries(); // assert Assert.IsTrue(result.Count == 2); Assert.IsTrue(result.Contains(addedCountry1)); Assert.IsTrue(result.Contains(addedCountry2)); 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 ArticleRepository(HAVIdatabaseContext context) { _context = context; }
public VailedForCustomerRepository(HAVIdatabaseContext context) { _context = context; }
public LocationRepository(HAVIdatabaseContext context) { _context = context; }
public FreightResponsibilityRepository(HAVIdatabaseContext context) { _context = context; }
public SupplierRepository(HAVIdatabaseContext context) { _context = context; }
public SAPPlantRepository(HAVIdatabaseContext context) { _context = context; }
public DepartmentIdRepository(HAVIdatabaseContext context) { _context = context; }
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(); }