Пример #1
0
        private async Task ExecuteMethodReturnsUserIsNull()
        {
            //Arrange
            var mocks = GetMocks();
            var users = GetUsers().AsQueryable().BuildMock();

            SetSettingsInDb(mocks.userMock, users);
            mocks.dbMock.Setup(m => m.Users).Returns(mocks.userMock.Object);

            var changeCity = new ChangeCityCommand(mocks.dbMock.Object);
            var message    = new Message()
            {
                Chat = new Chat()
                {
                    Id = 2
                },
                Text = "/changeName@Test"
            };

            var client = new TelegramBotClient(AppConfig.Token);

            //Act
            var result = await changeCity.Execute(message, client);

            //Assert
            Assert.NotNull(result);
            Assert.False(result?.isSuccessed);
            Assert.Equal("User is null", result?.Message);
        }
Пример #2
0
        private void ContaintMethodReturnsTrue()
        {
            //Arrange
            var dbMock     = new Mock <TelegramBotContext>();
            var changeCity = new ChangeCityCommand(dbMock.Object);
            var message    = new Message()
            {
                Text = "/changeCity"
            };

            //Act
            var result = changeCity.IsContains(message);

            //Assert
            Assert.True(result);
        }
Пример #3
0
        private void ContaintMethodReturnsFalse()
        {
            //Arrange
            var dbMock     = new Mock <TelegramBotContext>();
            var changeCity = new ChangeCityCommand(dbMock.Object);
            var message    = new Message()
            {
                Text = Guid.NewGuid().ToString()
            };

            //Act
            var result = changeCity.IsContains(message);

            //Assert
            Assert.False(result);
        }