public async Task AddAnswerToComment_WithNoneExistingEmailId_ShouldThrowsException() { // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var contactRecordsRepository = new EfDeletableEntityRepository <ContactFormRecords>(context); var emailSender = new FakeEmailSender(); var forUsService = new ForUsService(contactRecordsRepository, emailSender); var seeder = new DbContextTestsSeeder(); await seeder.SeedContactFormRecordsAsync(context); await Assert.ThrowsAsync <NullReferenceException>(() => forUsService.SendAnswer("Тестов Отговор", "Test Id")); }
public async Task AddAnswerToComment_WithCorrectData_ShouldSuccessfullyAdd() { // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var contactRecordsRepository = new EfDeletableEntityRepository <ContactFormRecords>(context); var emailSender = new FakeEmailSender(); var forUsService = new ForUsService(contactRecordsRepository, emailSender); var seeder = new DbContextTestsSeeder(); await seeder.SeedContactFormRecordsAsync(context); // Act var result = forUsService.SendAnswer("Тестов отговор", "comId1"); var expected = "Тестов отговор"; var actual = context.ContactForms.SingleOrDefault(c => c.Id == "comId1").Answer; // Assert AssertExtension.EqualsWithMessage(actual, expected, string.Format(ErrorMessage, "CreateAnswer")); }
public async Task TestGetAllComments_WithGivenType_ShouldReturnAllComments() { // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var contactRecordsRepository = new EfDeletableEntityRepository <ContactFormRecords>(context); var emailSender = new FakeEmailSender(); var forUsService = new ForUsService(contactRecordsRepository, emailSender); var seeder = new DbContextTestsSeeder(); await seeder.SeedContactFormRecordsAsync(context); AutoMapperConfig.RegisterMappings(typeof(CreateCommentInputModel).Assembly); var result = forUsService.GetAllSendEmails <ContactFormViewModel>(); var expected = result.ToList().Count; var actual = context.ContactForms.Count(); // Assert Assert.True(expected == actual, string.Format(ErrorMessage, "GetAllContactForm emails")); }