public async Task DeleteByIdAsync_WithCorrectData_ShouldSuccessfullyDelete() { var testContent = "TestContent"; // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var replyRepository = new EfDeletableEntityRepository <Reply>(context); var repliesService = new RepliesService(replyRepository); var inputModel = new CreateReplyInputModel() { Content = testContent, }; await repliesService.CreateAsync(inputModel); var reply = replyRepository.All().FirstOrDefault(c => c.Content == testContent); // Act var expectedCommentsCount = 0; await repliesService.DeleteByIdAsync(reply.Id); var actualCommentsCount = replyRepository.All().Count(); // Assert Assert.Equal(expectedCommentsCount, actualCommentsCount); }
public async Task DeleteByIdAsync_WithIncorrectData_ShouldThrowArgumentNullException() { var incorrectId = Guid.NewGuid().ToString(); // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var replyRepository = new EfDeletableEntityRepository <Reply>(context); var repliesService = new RepliesService(replyRepository); // Act // Assert await Assert.ThrowsAsync <ArgumentException>(async() => { await repliesService.DeleteByIdAsync(incorrectId); }); }