Ejemplo n.º 1
0
        public async Task Get_User_With_Zero_Id_Should_Return_Bad_Request()
        {
            // Arrange
            var fakeBotId = 0;

            _botRepositoryMock.Setup(x => x.GetBotAsync(It.IsAny <int>()));

            // Act
            var botController = new BotsController(
                _botRepositoryMock.Object,
                _botEventServiceMock.Object
                );

            var actionResult = (await botController.BotByIdAsync(fakeBotId)).Result as BadRequestResult;

            // Assert
            Assert.NotNull(actionResult);
        }
Ejemplo n.º 2
0
        public async Task Get_Nonexistent_Bot()
        {
            // Arrange
            var fakeBotId = 2;

            _botRepositoryMock.Setup(x => x.GetBotAsync(It.IsAny <int>()))
            .Returns(Task.FromResult((Bot)null));

            // Act
            var botController = new BotsController(
                _botRepositoryMock.Object,
                _botEventServiceMock.Object
                );

            var actionResult = (await botController.BotByIdAsync(fakeBotId)).Result as NotFoundResult;

            // Assert
            Assert.NotNull(actionResult);
        }
Ejemplo n.º 3
0
        public async Task Get_Bot_Success()
        {
            // Arrange
            var fakeBotId = 1;
            var fakeToken = "token";
            var fakeName  = "name";
            var fakeBot   = GetBotFake(fakeBotId, fakeToken, fakeName);

            _botRepositoryMock.Setup(x => x.GetBotAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(fakeBot));

            // Act
            var botController = new BotsController(
                _botRepositoryMock.Object,
                _botEventServiceMock.Object
                );

            var actionResult = await botController.BotByIdAsync(fakeBotId);

            // Assert
            Assert.AreEqual((actionResult.Result as OkObjectResult).StatusCode, (int)System.Net.HttpStatusCode.OK);
            Assert.AreEqual((((ObjectResult)actionResult.Result).Value as Bot).Id, fakeBot.Id);
        }