Beispiel #1
0
        public async Task ThrowExeptionWhenEmailBodyIsToLong_AddBodyToCurrentEmailAsync_Test()
        {
            var firstEmail = EmailGeneratorUtil.GenerateEmailFirst();

            var body = new String('T', 1001);

            var encodeDecodeServiceMock = new Mock <IEncodeDecodeService>().Object;
            var loggerMock = new Mock <ILogger <EmailService> >().Object;

            var options = TestUtilities.GetOptions(nameof(ThrowExeptionWhenEmailBodyIsToLong_AddBodyToCurrentEmailAsync_Test));

            using (var actContext = new E_MailApplicationsManagerContext(options))
            {
                var email = await actContext.Emails.AddAsync(firstEmail);


                await actContext.SaveChangesAsync();

                var emailDto = new EmailContentDto
                {
                    Body    = body,
                    GmailId = firstEmail.GmailId
                };

                var sut = new EmailService(actContext, loggerMock, encodeDecodeServiceMock);

                await sut.AddBodyToCurrentEmailAsync(emailDto);
            }
        }
Beispiel #2
0
        public async Task AddBodyToCurrentEmail_Test()
        {
            var body = "TestBody";

            var firstEmail = EmailGeneratorUtil.GenerateEmailFirst();

            var encodeDecodeServiceMock = new Mock <IEncodeDecodeService>().Object;
            var loggerMock = new Mock <ILogger <EmailService> >().Object;

            var options = TestUtilities.GetOptions(nameof(AddBodyToCurrentEmail_Test));

            using (var actContext = new E_MailApplicationsManagerContext(options))
            {
                var email = await actContext.Emails.AddAsync(firstEmail);

                await actContext.SaveChangesAsync();

                var emailDto = new EmailContentDto
                {
                    Body    = body,
                    GmailId = firstEmail.GmailId
                };

                var sut = new EmailService(actContext, loggerMock, encodeDecodeServiceMock);

                await sut.AddBodyToCurrentEmailAsync(emailDto);
            }

            using (var assertContext = new E_MailApplicationsManagerContext(options))
            {
                var sut = assertContext.Emails
                          .Select(emailBody => emailBody.Body)
                          .ToString();

                Assert.IsNotNull(sut);
            }
        }