Пример #1
0
        public async Task SetEmailStatusInvalidApplication_Test()
        {
            var user = UserGeneratorUtil.GenerateUser();

            var firstEmail = EmailGeneratorUtil.GenerateEmailFirst();

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

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

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

                var currentUser = await actContext.AddAsync(user);

                await actContext.SaveChangesAsync();

                var dto = new StatusInvalidApplicationDto
                {
                    GmailId = firstEmail.GmailId,
                    UserId  = currentUser.Entity.Id
                };

                var sut    = new EmailService(actContext, loggerMock, encodeDecodeServiceMock);
                var result = await sut.SetEmailStatusInvalidApplicationAsync(dto);

                Assert.IsTrue(result);
            }
        }
        public async Task SaveLastLoginUserReturFalseWhenUserIsNull_Test()
        {
            var user = UserGeneratorUtil.GenerateUser();

            user = null;

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

            using (var actContext = new E_MailApplicationsManagerContext(options))
            {
                var sut    = new LogService(actContext);
                var result = await sut.SaveLastLoginUser(user);

                Assert.IsFalse(result);
            }
        }
        public async Task SaveLastLoginUser_Test()
        {
            var user = UserGeneratorUtil.GenerateUser();

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

            using (var actContext = new E_MailApplicationsManagerContext(options))
            {
                await actContext.Users.AddAsync(user);

                await actContext.SaveChangesAsync();

                var sut    = new LogService(actContext);
                var result = await sut.SaveLastLoginUser(user);

                Assert.IsTrue(result);
            }
        }