Beispiel #1
0
        public void UpdatePasswordReset_Pass()
        {
            //Arrange
            var newUser = tu.CreateUserObject();

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

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

                // Assert
                Assert.IsNotNull(response);
                Assert.IsNotNull(result);
                Assert.AreEqual(result.ResetToken, expectedResult.ResetToken);
                Assert.AreNotEqual(result.ExpirationTime, expectedResultExpirationTime);
            }
        }
Beispiel #2
0
        public void UpdatePasswordReset_Fail()
        {
            //Arrange
            var newUser = tu.CreateUserObject();

            newPasswordReset = tu.CreatePasswordResetObject(newUser);
            PasswordReset expectedResult = newPasswordReset;

            //Act
            using (var _db = tu.CreateDataBaseContext())
            {
                ResetService rs       = new ResetService(_db);
                var          response = rs.UpdatePasswordReset(newPasswordReset);
                try
                {
                    _db.SaveChanges();
                }
                catch (Exception)
                {
                    // catch error
                    // rollback changes
                    _db.Entry(newPasswordReset).State = System.Data.Entity.EntityState.Detached;
                }
                var result = rs.GetPasswordReset(expectedResult.ResetToken);

                // Assert
                Assert.IsNotNull(response);
                Assert.IsNull(result);
            }
        }