Пример #1
0
        public void GetState_EmptyUser_TrowsException()
        {
            var messageRegister = new MessageRegister();
            var user            = new User {
                ChatId = "null", MessengerClass = null
            };
            var message = new Message(user)
            {
                BasicText = "Test"
            };

            var ex = Assert.Catch <Exception>(() => messageRegister.GetState(message));

            StringAssert.Contains("Message doesn't register", ex.Message);
        }
Пример #2
0
        public void GetState_UnknownMessage_ThrowException()
        {
            var messageRegister = new MessageRegister();
            var user            = new User {
                ChatId = "123456", MessengerClass = nameof(FakeMessengerApi)
            };
            var message = new Message(user)
            {
                BasicText = "Test"
            };

            var ex = Assert.Catch <Exception>(() => messageRegister.GetState(message));


            StringAssert.Contains("Message doesn't register", ex.Message);
        }
Пример #3
0
        public void GetState_WhenCall_SetStateToUser()
        {
            var messageRegister = new MessageRegister();
            var user            = new User {
                ChatId = "123456", MessengerClass = nameof(FakeMessengerApi)
            };
            var message = new Message(user)
            {
                BasicText = "Test"
            };

            messageRegister.RegisterMessage(message);

            messageRegister.SetState(message, UserStates.SecondLevel);
            var states = messageRegister.GetState(message);

            Assert.AreEqual(UserStates.SecondLevel, states);
        }