public void AuthorizeServiceConstructorTest()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembershipProvider provider = mocks.StrictMock<IMembershipProvider>();
            AuthorizeService target  = null;
            using (mocks.Record()) { /*nothing to record */  }

            using (mocks.Playback())
            {
                target = new AuthorizeService(provider);
            }
            Assert.IsNotNull(target);
        }
        public void AuthorizeUserTestWithNotNullModelAndExceptionValidate()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembershipProvider provider = mocks.StrictMock<IMembershipProvider>();
            AuthorizeService target = new AuthorizeService(provider);
            ILogOnMemberModel model = mocks.StrictMock<ILogOnMemberModel>();

            bool expected = false;
            bool actual;

            using (mocks.Record())
            {
                Expect.Call(model.UserName).Return("");
                Expect.Call(model.Password).Return("");
                Expect.Call(provider.ValidateMember("", "")).Throw(new Exception());
            }

            using (mocks.Playback())
            {
                actual = target.AuthorizeMember(model);
            }
            Assert.AreEqual(expected, actual);
        }
 public void AuthorizeUserTestWithNullModel()
 {
     // Arrange
     MockRepository mocks = new MockRepository();
     IMembershipProvider provider = mocks.StrictMock<IMembershipProvider>();
     AuthorizeService target = new AuthorizeService(provider);
     ILogOnMemberModel model = null;
     bool expected = false;
     bool actual;
     using (mocks.Record()) { /*nothing to record */  }
     using (mocks.Playback())
     {
         actual = target.AuthorizeMember(model);
     }
     Assert.AreEqual(expected, actual);
 }
        public void AuthorizeUserTestWithNotNullModelAndTrueValidateAndRememberMeValuePass()
        {
            // Arrange
            MockRepository mocks = new MockRepository();
            IMembershipProvider provider = mocks.StrictMock<IMembershipProvider>();
            AuthorizeService target = new AuthorizeService(provider);
            ILogOnMemberModel model = mocks.StrictMock<ILogOnMemberModel>();

            bool expected = true;
            bool actual;

            using (mocks.Record())
            {
                Expect.Call(model.UserName).Return("");
                Expect.Call(model.Password).Return("");
                Expect.Call(provider.ValidateMember("", "")).Return(true);
                Expect.Call(model.UserName).Return("");
                Expect.Call(model.Password).Return("");
                Expect.Call(model.RememberMe).Return(true);
                Expect.Call(provider.SetAuthCookie("", "", true)).Return(true);
            }

            using (mocks.Playback())
            {
                actual = target.AuthorizeMember(model);
            }
            Assert.AreEqual(expected, actual);
        }