public async Task TestCreateInvalidUser() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); HomeownerSevice homeownerSevice = new HomeownerSevice(context); ACMUser user = new ACMUser { Email = "*****@*****.**" }; await context.Users.AddAsync(user); await context.SaveChangesAsync(); await Assert.ThrowsAsync <ACMException>(() => homeownerSevice.Create("beer", "NOT [email protected]")); }
public async Task TestCreateGoodData() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); HomeownerSevice homeownerSevice = new HomeownerSevice(context); ACMUser user = new ACMUser { Email = "*****@*****.**" }; await context.Users.AddAsync(user); await context.SaveChangesAsync(); string id = await homeownerSevice.Create("beer", "*****@*****.**"); Assert.Single(context.Ideas.ToList()); Assert.Equal("beer", context.Ideas .Where(x => x.Id == id) .FirstOrDefault() .Text); Assert.Equal("*****@*****.**", context.Ideas .Where(x => x.Id == id) .FirstOrDefault() .User.Email); }