public async Task TestDeleteIdeaGoodData() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); HomeownerSevice homeownerSevice = new HomeownerSevice(context); ACMUser user = new ACMUser { Email = "*****@*****.**", FullName = "gosho" }; Idea idea1 = new Idea { Id = "1", User = user, Text = "idea1" }; Idea idea2 = new Idea { Id = "2", User = user, Text = "idea2" }; await context.Users.AddAsync(user); await context.Ideas.AddAsync(idea1); await context.Ideas.AddAsync(idea2); await context.SaveChangesAsync(); bool output = await homeownerSevice.DeleteIdea(idea1.Id, user.Email); Assert.True(output); Assert.Single(context.Ideas.ToList()); Assert.True(context.Ideas.Any(x => x.Id == idea2.Id)); }
public async Task TestDeleteIdeaInvalidId() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); HomeownerSevice homeownerSevice = new HomeownerSevice(context); ACMUser user = new ACMUser { Email = "*****@*****.**", FullName = "gosho" }; Idea idea1 = new Idea { Id = "1", User = user, Text = "idea1" }; Idea idea2 = new Idea { Id = "2", User = user, Text = "idea2" }; await context.Users.AddAsync(user); await context.Ideas.AddAsync(idea1); await context.Ideas.AddAsync(idea2); await context.SaveChangesAsync(); await Assert.ThrowsAsync <ACMException>(() => homeownerSevice.DeleteIdea(idea1.Id + "Random string", user.Email)); }