public async Task Should_Save_Email()
        {
            var command = EmailFaker.GenerateEmailViewModel().Generate();
            var result  = await _emailAppService.SaveEmail(command);

            result.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey());
            _database.Emails.FirstOrDefault(f => f.Type == command.Type).Should().NotBeNull();
        }
        public async Task Should_Save_Email_With_Many_Bccs()
        {
            var command  = EmailFaker.GenerateEmailViewModel().Generate();
            var emailBcc = _faker.Person.Email;

            command.Bcc = $"{emailBcc};{_faker.Internet.Email()};{_faker.Internet.Email()};{_faker.Internet.ExampleEmail()}";

            var result = await _emailAppService.SaveEmail(command);

            result.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey());
        }
        public async Task Should_Find_Email_By_Type()
        {
            var command = EmailFaker.GenerateEmailViewModel().Generate();
            await _emailAppService.SaveEmail(command);

            var email = await _emailAppService.FindByType(command.Type);

            _database.Emails.FirstOrDefault(f => f.Type == command.Type).Should().NotBeNull();
            email.Should().NotBeNull();
            email.Sender.Should().NotBeNull();
            email.Sender.Name.Should().NotBeNull();
            email.Sender.Address.Should().NotBeNull();
        }
Exemplo n.º 4
0
        public async Task ShouldSaveEmailWithManyBccs()
        {
            var command  = EmailFaker.GenerateEmailViewModel().Generate();
            var emailBcc = _faker.Person.Email;

            command.Bcc = $"{emailBcc};{_faker.Internet.Email()};{_faker.Internet.Email()};{_faker.Internet.ExampleEmail()}";

            var result = await _emailAppService.SaveEmail(command);

            result.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey());
            var email = _database.Emails.FirstOrDefault(f => f.Type == command.Type);

            email.Bcc.Recipients.Should().Contain(s => s.Equals(emailBcc));
        }
        public async Task Should_Update_Email_With_Null_Bcc()
        {
            var command = EmailFaker.GenerateEmailViewModel().Generate();

            var result = await _emailAppService.SaveEmail(command);

            result.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey());
            var email = _database.Emails.FirstOrDefault(f => f.Type == command.Type);

            email.Should().NotBeNull();

            command.Bcc     = new BlindCarbonCopy();
            command.Content = _faker.Lorem.Paragraphs();

            await _emailAppService.SaveEmail(command);

            email = _database.Emails.FirstOrDefault(f => f.Type == command.Type);
            email.Should().NotBeNull();
        }