public async void DeleteFeedbackCorrectly() { var dbContext = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var feedbackRepository = new EfDeletableEntityRepository <Feedback>(new ApplicationDbContext(dbContext.Options)); feedbackRepository.SaveChangesAsync().GetAwaiter().GetResult(); var service = new FeedbacksService(feedbackRepository); var user = new ApplicationUser { Id = Guid.NewGuid().ToString(), }; var meeting = new Meeting { Id = Guid.NewGuid().ToString(), Title = "Test 1", }; await service.AddAsync(user.Id, user, 6, "Awesome", meeting.Id, meeting); var id = feedbackRepository.All().Where(f => f.MeetingId == meeting.Id).First().Id; var feedback = service.GetFeedbackById(id); await service.Delete(feedback); var list = service.GetAllFeedbacks(); Assert.Empty(list); }
public async void GetFeedbackByIdCorrectly() { var dbContext = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var feedbackRepository = new EfDeletableEntityRepository <Feedback>(new ApplicationDbContext(dbContext.Options)); feedbackRepository.SaveChangesAsync().GetAwaiter().GetResult(); var service = new FeedbacksService(feedbackRepository); var user = new ApplicationUser { Id = Guid.NewGuid().ToString(), }; var meeting = new Meeting { Id = Guid.NewGuid().ToString(), Title = "Test 1", }; var secondMeeting = new Meeting { Id = Guid.NewGuid().ToString(), Title = "Test 2", }; await service.AddAsync(user.Id, user, 6, "Awesome", meeting.Id, meeting); await service.AddAsync("Not user id", new ApplicationUser { }, 1, "Poor", secondMeeting.Id, secondMeeting); var id = feedbackRepository.All().Where(f => f.MeetingId == secondMeeting.Id).First().Id; var feedback = service.GetFeedbackById(id); Assert.Equal(1, feedback.Rating); Assert.Equal("Poor", feedback.Description); }