Ejemplo n.º 1
0
        public void GetPasswordReset_Pass()
        {
            //Arrange

            var newUser = tu.CreateUserObject();

            newPasswordReset = tu.CreatePasswordResetObject(newUser);
            var expected = newPasswordReset;

            //Act
            using (var _db = tu.CreateDataBaseContext())
            {
                ResetService rs = new ResetService(_db);
                newPasswordReset = rs.CreatePasswordReset(newPasswordReset);
                try
                {
                    _db.SaveChanges();
                }
                catch (Exception exception)
                {
                }
                var result = rs.GetPasswordReset(newPasswordReset.ResetToken);
                //Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(result.ResetToken, expected.ResetToken);
            }
        }
Ejemplo n.º 2
0
        public void CreatePasswordReset_Fail()
        {
            //Arrange
            var newUser = tu.CreateUserObject();

            newPasswordReset = tu.CreatePasswordResetObject(newUser);
            var expected = tu.CreatePasswordResetObject(newUser);

            //Act
            using (var _db = tu.CreateDataBaseContext())
            {
                ResetService rs       = new ResetService(_db);
                var          response = rs.CreatePasswordReset(newPasswordReset);
                try
                {
                    _db.SaveChanges();
                }
                catch (Exception exception)
                {
                }
                //Assert
                Assert.IsNotNull(response);
                Assert.AreNotEqual(response, expected);
            }
        }
Ejemplo n.º 3
0
        public void UpdatePasswordReset_Pass()
        {
            //Arrange
            var newUser = tu.CreateUserObject();

            newPasswordReset = tu.CreatePasswordResetObject(newUser);
            var expectedResultExpirationTime = newPasswordReset.ExpirationTime;
            var expectedResult = newPasswordReset;

            //Act
            using (var _db = tu.CreateDataBaseContext())
            {
                ResetService rs = new ResetService(_db);
                newPasswordReset = rs.CreatePasswordReset(newPasswordReset);
                try
                {
                    _db.SaveChanges();
                }
                catch (Exception exception)
                {
                }
                newPasswordReset.ExpirationTime = DateTime.Now.AddYears(5);
                var response = rs.UpdatePasswordReset(newPasswordReset);
                _db.SaveChanges();
                var result = rs.GetPasswordReset(expectedResult.ResetToken);

                // Assert
                Assert.IsNotNull(response);
                Assert.IsNotNull(result);
                Assert.AreEqual(result.ResetToken, expectedResult.ResetToken);
                Assert.AreNotEqual(result.ExpirationTime, expectedResultExpirationTime);
            }
        }
Ejemplo n.º 4
0
        public void CreatePasswordReset_Pass()
        {
            //Arrange
            var newUser = tu.CreateUserObject();

            newPasswordReset = tu.CreatePasswordResetObject(newUser);
            var expected = newPasswordReset;

            //Act
            using (var _db = tu.CreateDataBaseContext())
            {
                ResetService rs       = new ResetService(_db);
                var          response = rs.CreatePasswordReset(newPasswordReset);
                _db.SaveChanges();

                //Assert
                Assert.IsNotNull(response);
                Assert.AreEqual(response.ResetToken, expected.ResetToken);
            }
        }
Ejemplo n.º 5
0
        public void ExistingPasswordReset_Pass()
        {
            //Arrange
            var newUser = tu.CreateUserObject();

            newPasswordReset = tu.CreatePasswordResetObject(newUser);
            var expected = true;

            //Act
            using (var _db = tu.CreateDataBaseContext())
            {
                ResetService rs = new ResetService(_db);
                rs.CreatePasswordReset(newPasswordReset);
                _db.SaveChanges();
                var actual = rs.ExistingReset(newPasswordReset.ResetToken);
                //Assert
                Assert.IsNotNull(actual);
                Assert.AreEqual(actual, expected);
            }
        }