Exemple #1
0
        public async Task AddAttachment_Test()
        {
            var    gmailId  = "TestGmailId";
            var    FileName = "TestFileName";
            double fileSize = 876.77;

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

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

            using (var actContext = new E_MailApplicationsManagerContext(options))
            {
                await actContext.EmailAttachments.AddAsync(
                    new EmailAttachment
                {
                    GmailId  = gmailId,
                    FileName = FileName,
                    SizeInKB = fileSize
                });

                await actContext.SaveChangesAsync();

                var ettachmentDto = new EmailAttachmentDTO
                {
                    FileName = FileName,
                    GmailId  = gmailId,
                    SizeInKB = fileSize
                };

                var sut    = new EmailService(actContext, loggerMock, encodeDecodeServiceMock);
                var result = sut.AddAttachmentAsync(ettachmentDto);

                Assert.IsNotNull(result);
            }
            using (var assertContext = new E_MailApplicationsManagerContext(options))
            {
                Assert.AreEqual(2, assertContext.EmailAttachments.Count());
            }
        }
Exemple #2
0
        public async Task ThrowExeptionWhenAddAttachmentNameIsMinLenght_Test()
        {
            var    gmailId  = "TestGmailId";
            var    FileName = "Test";
            double fileSize = 876.77;

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

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

            using (var actContext = new E_MailApplicationsManagerContext(options))
            {
                var ettachmentDto = new EmailAttachmentDTO
                {
                    FileName = FileName,
                    GmailId  = gmailId,
                    SizeInKB = fileSize
                };

                var sut = new EmailService(actContext, loggerMock, encodeDecodeServiceMock);
                await sut.AddAttachmentAsync(ettachmentDto);
            }
        }