コード例 #1
0
        public async Task VerifyNewRequestAsync_ReturnsFalse_WhenLockedOut()
        {
            // Arrange
            var service = new AccessLogService(_context);

            var previousAttempts = new List <AccessLog>()
            {
                new AccessLog
                {
                    IsSuccess         = false,
                    IsLockedOut       = false,
                    SubmittedDateTime = DateTime.Now.AddMinutes(-3),
                    UserName          = "******",
                    EmailAddress      = "*****@*****.**",
                    DOB = DateTime.Now.AddYears(-10)
                },
                new AccessLog
                {
                    IsSuccess         = false,
                    IsLockedOut       = false,
                    SubmittedDateTime = DateTime.Now.AddMinutes(-2),
                    UserName          = "******",
                    EmailAddress      = "*****@*****.**",
                    DOB = DateTime.Now.AddYears(-10)
                },
                new AccessLog
                {
                    IsSuccess         = false,
                    IsLockedOut       = false,
                    SubmittedDateTime = DateTime.Now.AddMinutes(-1),
                    UserName          = "******",
                    EmailAddress      = "*****@*****.**",
                    DOB = DateTime.Now.AddYears(-10)
                }
            };

            _context.AddRange(previousAttempts);
            _context.SaveChanges();


            var lockoutAttempt = new AccessLog
            {
                UserName     = "******",
                EmailAddress = "*****@*****.**",
                DOB          = DateTime.Now.AddYears(-20)
            };

            // Act
            var result = await service.VerifyNewRequestAsync(lockoutAttempt);

            // Assert
            Assert.IsFalse(result);
        }
コード例 #2
0
        public async Task VerifyNewRequestAsync_ReturnsFalse_WhenNotPermissible()
        {
            // Arrange
            var service = new AccessLogService(_context);

            var accessLog = new AccessLog
            {
                UserName     = "******",
                EmailAddress = "*****@*****.**",
                DOB          = DateTime.Now.AddYears(-10)
            };

            // Act
            var result = await service.VerifyNewRequestAsync(accessLog);

            // Assert
            Assert.IsFalse(result);
        }