Example #1
0
        public void Login_NullAsParameter_CannotExecute()
        {
            IUserRepository fakeUserRepository = A.Fake<IUserRepository>();
            var fakeLogin = A.Fake<ILoginActions>();
            List<string> parameters = new List<string> { null };

            var login = new Login(fakeUserRepository, fakeLogin, parameters);

            Assert.AreEqual(false, login.CanExecute());
        }
Example #2
0
        public void Login_UserDoesntExist_CannotExecute()
        {
            const string NON_EXISTING_USER = "******";
            IUserRepository fakeUserRepository = A.Fake<IUserRepository>();
            var fakeLogin = A.Fake<ILoginActions>();
            A.CallTo(() => fakeUserRepository.IsExists(NON_EXISTING_USER)).Returns(false);
            List<string> parameters = new List<string> { NON_EXISTING_USER };

            var login = new Login(fakeUserRepository, fakeLogin, parameters);

            Assert.AreEqual(false, login.CanExecute());
        }
Example #3
0
        public void Login_TooMuchParameters_CannotExecute()
        {
            const string SOME_PARAMETER_VALUE = "NonSegnificantValue";

            IUserRepository fakeUserRepository = A.Fake<IUserRepository>();
            var fakeLogin = A.Fake<ILoginActions>();
            List<string> parameters = new List<string> { SOME_PARAMETER_VALUE, SOME_PARAMETER_VALUE };

            var login = new Login(fakeUserRepository, fakeLogin, parameters);

            Assert.AreEqual(false, login.CanExecute());
        }
Example #4
0
        public void Login_UserExist_CommandPassed()
        {
            const string EXISTING_USER = "******";
            IUserRepository fakeUserRepository = A.Fake<IUserRepository>();
            var fakeLogin = A.Fake<ILoginActions>();
            A.CallTo(() => fakeUserRepository.IsExists(EXISTING_USER)).Returns(true);
            List<string> parameters = new List<string> { EXISTING_USER };

            var login = new Login(fakeUserRepository, fakeLogin, parameters);

            Assert.AreEqual(true, login.CanExecute());
            Assert.AreEqual("OK", login.Execute());
        }