public async Task GetUserAccountCodeByAccountId_AccountIdExists_ReturnBusinessUserAccountCodeModel(int id, string code,
                                                                                                           string expirationTime, int accountId)
        {
            // Arrange
            IDataGateway               dataGateway               = new SQLServerGateway();
            IConnectionStringData      connectionString          = new ConnectionStringData();
            IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString);

            var expectedResult = new BusinessUserAccountCodeModel();

            expectedResult.Id             = id;
            expectedResult.Code           = code;
            expectedResult.ExpirationTime = DateTimeOffset.Parse(expirationTime);
            expectedResult.UserAccountId  = accountId;

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository);

            // Act
            var actualResult = await userAccountCodeService.GetUserAccountCodeByAccountId(accountId);

            // Assert
            Assert.IsTrue
            (
                actualResult.Id == expectedResult.Id &&
                actualResult.Code == expectedResult.Code &&
                actualResult.ExpirationTime == expectedResult.ExpirationTime &&
                actualResult.UserAccountId == expectedResult.UserAccountId
            );
        }
        public async Task AddCode_AccountIdDoesntExists_ReturnTrue(string code,
                                                                   string expirationTime, int accountId, string username, string password, string salt, string emailAddress,
                                                                   string accountType, string accountStatus, string creationDate, string updationDate)
        {
            // Arrange
            IDataGateway               dataGateway               = new SQLServerGateway();
            IConnectionStringData      connectionString          = new ConnectionStringData();
            IUserAccountRepository     userAccountRepository     = new UserAccountRepository(dataGateway, connectionString);
            IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString);

            var userAccountModel = new UserAccountModel();

            userAccountModel.Id            = accountId;
            userAccountModel.Username      = username;
            userAccountModel.Password      = password;
            userAccountModel.Salt          = salt;
            userAccountModel.EmailAddress  = emailAddress;
            userAccountModel.AccountType   = accountType;
            userAccountModel.AccountStatus = accountStatus;
            userAccountModel.CreationDate  = DateTimeOffset.Parse(creationDate);
            userAccountModel.UpdationDate  = DateTimeOffset.Parse(updationDate);

            await userAccountRepository.CreateAccount(userAccountModel);

            var expectedResult = true;

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository);

            // Act
            var actualResult = await userAccountCodeService.AddCode(code, DateTimeOffset.Parse(expirationTime), accountId);

            // Assert
            Assert.IsTrue(actualResult == expectedResult);
        }
        public async Task GetUserAccountCodeByAccountId_AccountIdDoesntExists_ReturnNull(int accountId)
        {
            // Arrange
            IDataGateway               dataGateway               = new SQLServerGateway();
            IConnectionStringData      connectionString          = new ConnectionStringData();
            IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString);

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository);

            // Act
            var actualResult = await userAccountCodeService.GetUserAccountCodeByAccountId(accountId);

            // Assert
            Assert.IsNull(actualResult);
        }
        public async Task DeleteCodeByAccountId_AccountIdExists_ReturnTrue(int accountId)
        {
            // Arrange
            IDataGateway               dataGateway               = new SQLServerGateway();
            IConnectionStringData      connectionString          = new ConnectionStringData();
            IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString);

            var expectedResult = true;

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository);

            // Act
            var actualResult = await userAccountCodeService.DeleteCodeByAccountId(accountId);

            // Assert
            Assert.IsTrue(actualResult == expectedResult);
        }
        public async Task UpdateCode_AccountIdExists_ReturnTrue(string code, string expirationTime, int accountId)
        {
            // Arrange
            IDataGateway               dataGateway               = new SQLServerGateway();
            IConnectionStringData      connectionString          = new ConnectionStringData();
            IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString);

            var expectedResult = true;

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository);

            // Act
            var actualResult = await userAccountCodeService.UpdateCodeByAccountId(code, DateTimeOffset.Parse(expirationTime),
                                                                                  accountId);

            // Assert
            Assert.IsTrue(actualResult == expectedResult);
        }
        public async Task GetUserAccountCodeByAccountId_AccountIdNotFound_ReturnNull(int accountId)
        {
            // Arrange
            // Setting up each dependency of LoginAttemptsService as a Mock
            Mock <IUserAccountCodeRepository> mockUserAccountCodeRepository = new Mock <IUserAccountCodeRepository>();

            UserAccountCodeModel userAccountCodeModel = null;

            mockUserAccountCodeRepository.Setup(x => x.GetUserAccountCodeByAccountId(accountId)).Returns
                (Task.FromResult(userAccountCodeModel));

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(mockUserAccountCodeRepository.Object);

            // Act
            var actualResult = await userAccountCodeService.GetUserAccountCodeByAccountId(accountId);

            // Assert
            Assert.IsNull(actualResult);
        }
        public async Task GetUserAccountCodeByAccountId_AccountIdFound_ReturnBusinessUserAccountCodeModel(int id, string code,
                                                                                                          string expirationTime, int accountId)
        {
            // Arrange
            // Setting up each dependency of LoginAttemptsService as a Mock
            Mock <IUserAccountCodeRepository> mockUserAccountCodeRepository = new Mock <IUserAccountCodeRepository>();

            var userAccountCodeModel = new UserAccountCodeModel();

            userAccountCodeModel.Id             = id;
            userAccountCodeModel.Code           = code;
            userAccountCodeModel.ExpirationTime = DateTimeOffset.Parse(expirationTime);
            userAccountCodeModel.UserAccountId  = accountId;

            var expectedResult = new BusinessUserAccountCodeModel();

            expectedResult.Id             = id;
            expectedResult.Code           = code;
            expectedResult.ExpirationTime = DateTimeOffset.Parse(expirationTime);
            expectedResult.UserAccountId  = accountId;

            mockUserAccountCodeRepository.Setup(x => x.GetUserAccountCodeByAccountId(accountId)).Returns
                (Task.FromResult(userAccountCodeModel));

            IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(mockUserAccountCodeRepository.Object);

            // Act
            var actualResult = await userAccountCodeService.GetUserAccountCodeByAccountId(accountId);

            // Assert
            Assert.IsTrue
            (
                actualResult.Id == expectedResult.Id &&
                actualResult.Code == expectedResult.Code &&
                actualResult.ExpirationTime == expectedResult.ExpirationTime &&
                actualResult.UserAccountId == expectedResult.UserAccountId
            );
        }