예제 #1
0
        public void IsLoginOK_ValidUserAndPassword_LogsMessage()
        {
            var logger = FakeLogerFactory();
            var lm     = new FakeLoginManager(logger);

            lm.AddUser("a", "b");

            lm.IsLoginOK("a", "b");

            Assert.AreEqual("login ok: user: a", logger.LastMessage());
        }
예제 #2
0
        public void IsLoginOK_CallStaticLogger_LogsCorrectMessage()
        {
            var logger = FakeLogerFactory();
            var lm     = new FakeLoginManager(logger);

            lm.AddUser("a", "b");

            lm.IsLoginOK("a", "b");

            Assert.AreEqual("user a logged in ok", lm.Message);
        }
예제 #3
0
        public void IsLoginOK_CallStaticLogger_LogsCorrectMessage()
        {
            var machineName = "machineName";
            var lm          = new FakeLoginManager(machineName);

            lm.AddUser("a", "b");

            lm.IsLoginOK("a", "b");

            Assert.AreEqual("12.12.12 12:33:55 My Exception machineName", lm.Message);
        }
예제 #4
0
        public void IsLoginOK_UsingMoq_ValidUserAndPassword_LogsMessage()
        {
            var loggerMock = new Mock <ILogger>();

            var lm = new FakeLoginManager(loggerMock.Object);

            lm.AddUser("a", "b");

            lm.IsLoginOK("a", "b");

            loggerMock.Verify(_ => _.Write("login ok: user: a"), Times.Once);
        }
예제 #5
0
        public void IsLoginOK_WhenLoggerThrowsException_LogsCorrectMessage()
        {
            var mockWs = new Mock <IWebService>();
            var logger = FakeLogerFactory(mockWs.Object, willThrowException: true);
            var lm     = new FakeLoginManager(logger);

            lm.AddUser("a", "b");

            lm.IsLoginOK("a", "b");

            mockWs.Verify(_ => _.Write(It.IsAny <string>()), Times.Once);
        }
예제 #6
0
        public void IsLoginOK_ValidUserAndPassword_FailsToCompareHashtable(
            string addUserName, string addPassword,
            string checkUserName, string checkPassword)
        {
            var logger = FakeLogerFactory();
            var lm     = new FakeLoginManager(logger);

            lm.AddUser(addUserName, addPassword);

            lm.IsLoginOK(checkUserName, checkPassword);

            Assert.AreEqual(string.Format("login ok: user: {0}", checkUserName), logger.LastMessage());
        }
예제 #7
0
        public void IsLoginOK_UsingMock_InvalidUserOrPassword_LogsMessage(
            string addUserName, string addPassword,
            string checkUserName, string checkPassword)
        {
            var logger = new Mock <ILogger>();
            var lm     = new FakeLoginManager(logger.Object);

            lm.AddUser(addUserName, addPassword);

            lm.IsLoginOK(checkUserName, checkPassword);

            logger.Verify(_ => _.Write(string.Format("bad login: {0},{1}", checkUserName, checkPassword)), Times.Once);
        }
예제 #8
0
        public void IsLoginOK_InvalidUserOrPassword_LogsMessage(
            string addUserName, string addPassword,
            string checkUserName, string checkPassword)
        {
            var logger = FakeLogerFactory();
            var lm     = new FakeLoginManager(logger);

            lm.AddUser(addUserName, addPassword);

            lm.IsLoginOK(checkUserName, checkPassword);

            Assert.AreEqual(string.Format("bad login: {0},{1}", checkUserName, checkPassword), logger.LastMessage());
        }
예제 #9
0
        public void IsLoginOK_ValidUserAndPassword_FailsToCompareHashtable()
        {
            var logger = FakeLogerFactory();
            var lm     = new FakeLoginManager(logger);

            var addUserName   = new string(new [] { 'a' });
            var addPassword   = new string(new[] { 'b' });
            var checkUserName = new string(new[] { 'a' });
            var checkPassword = new string(new[] { 'b' });

            lm.AddUser(addUserName, addPassword);

            lm.IsLoginOK(checkUserName, checkPassword);

            Assert.AreEqual("login ok: user: a", logger.LastMessage());
        }