public void ValidatePasswordTest_ExpiredPassword()
        {
            // Arrange
            PasswordController generateController = new PasswordController();

            // Act

            // generates the password
            JsonResult passwordResult = generateController.GeneratePassword(validUserId) as JsonResult;
            dynamic passwordData = passwordResult.Data;
            String password = passwordData.data;

            // creates an UtcNow date with 31 seconds delay
            var a = DateTime.UtcNow;
            DateTime delayedDate = DateTime.UtcNow.AddSeconds(31);

            // uses a mock context that makes the DateTime.UtcNow return the delayed date
            Smock.Run(context =>
            {
                context.Setup(() => DateTime.UtcNow).Returns(delayedDate);

                PasswordController validateController = new PasswordController();
                JsonResult result = validateController.ValidatePassword(validUserId, password) as JsonResult;
                dynamic data = result.Data;

                // Assert
                Assert.AreEqual(data.status, false);
            });
        }
        public void ValidatePasswordTest_ValidPassword()
        {
            // Arrange
            PasswordController controller = new PasswordController();

            // Act

            // generates the password
            JsonResult passwordResult = controller.GeneratePassword(validUserId) as JsonResult;
            dynamic passwordData = passwordResult.Data;
            String password = passwordData.data;

            // uses the password
            JsonResult result = controller.ValidatePassword(validUserId, password) as JsonResult;
            dynamic data = result.Data;

            // Assert
            Assert.AreEqual(data.status, true);
        }
        public void ValidatePasswordTest_ValidPasswordTwoTimes()
        {
            // Arrange
            PasswordController controller = new PasswordController();

            // Act

            // generates the password
            JsonResult passwordResult = controller.GeneratePassword(validUserId) as JsonResult;
            dynamic passwordData = passwordResult.Data;
            String password = passwordData.data;

            // uses the password for the first time
            JsonResult firstTimeResult = controller.ValidatePassword(validUserId, password) as JsonResult;
            dynamic firstTimeData = firstTimeResult.Data;

            // uses the password for the second time
            JsonResult secondTimeResult = controller.ValidatePassword(validUserId, password) as JsonResult;
            dynamic secondTimeData = secondTimeResult.Data;

            // Assert
            Assert.AreEqual(firstTimeData.status, true);
            Assert.AreEqual(secondTimeData.status, false);
        }
        public void ValidatePasswordTest_InvalidUser()
        {
            // Arrange
            PasswordController controller = new PasswordController();

            // Act
            JsonResult result = controller.ValidatePassword(invalidUserId, "000000") as JsonResult;
            dynamic data = result.Data;

            // Assert
            Assert.AreEqual(data.status, false);
        }