public async Task TestGetIdeaInvalidId() { 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(); Action act = () => homeownerSevice .GetIdea(idea1.Id + "Random string", user.Email); Assert.Throws <ACMException>(act); }
public async Task TestGetIdeaGoodData() { 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(); EditIdeaDTO output = homeownerSevice.GetIdea(idea1.Id, user.Email); Assert.Equal(idea1.Text, output.Text); Assert.Equal(idea1.Id, output.Id); }