public void GetCompanyWithFakeId() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options)); repository.AddAsync(new ApplicationUser() { Description = "test", Type = UserType.Employer, }); repository.SaveChangesAsync().GetAwaiter().GetResult(); var company = new CompaniesService(repository); AutoMapperConfig.RegisterMappings(typeof(CompaniesServiceTests.MyTest).Assembly); Assert.Null(company.GetCompanyAsync <MyTest>("dasdasads")); }
public void GetCompanyWithId() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options)); var user = new ApplicationUser() { Email = "test", Description = "test", Type = UserType.Employer, }; repository.AddAsync(user); repository.SaveChangesAsync().GetAwaiter().GetResult(); var companyService = new CompaniesService(repository); AutoMapperConfig.RegisterMappings(typeof(CompaniesServiceTests.MyTest).Assembly); var company = companyService.GetCompanyAsync <MyTest>(user.Id); Assert.Equal("test", company.Email); repository.Delete(user); repository.SaveChangesAsync().GetAwaiter().GetResult(); }