Exemplo n.º 1
0
        public void Get()
        {
            IActionResult result = controller.Get();

            Assert.NotNull(result);
            Assert.AreEqual(((result as OkObjectResult).Value as List <PilotDto>).Count, testList.Count);
        }
Exemplo n.º 2
0
        public async Task PilotControllerReturnsCorrectId()
        {
            var result = (await _pilotsController.Get(5) as OkObjectResult)?.Value as PilotDto;

            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.Id);
        }
        public void Get_When_id_called_Then_return_status_code_200()
        {
            var service = A.Fake <IService <PilotDto> >();

            A.CallTo(() => service.GetAll()).Returns(new List <PilotDto>());
            var controller = new PilotsController(service);

            var result = controller.Get() as ObjectResult;

            Assert.AreEqual(200, result.StatusCode);
        }
Exemplo n.º 4
0
        public void Get_When_get_by_id_called_and_id_dont_exists_Then_return_status_code_404()
        {
            var service = A.Fake <IPilotService>();
            var id      = 23221;

            A.CallTo(() => service.Get(id)).Throws(new Exception());
            var controller = new PilotsController(service);

            var result = controller.Get(id) as ObjectResult;

            Assert.AreEqual(404, result.StatusCode);
        }
Exemplo n.º 5
0
        public void Get_WhenListIsNotNull_Returns_Status200()
        {
            var ServiceMock = new Mock <IService <PilotDTO> >();

            ServiceMock.Setup(s => s.GetAllAsync())
            .Returns(Task.FromResult(new List <PilotDTO>()
            {
                new PilotDTO {
                    Id = 1, FirstName = "Sasha", LastName = "Sidorov", Experience = 5
                }
            }.AsEnumerable()));

            PilotsController controller = new PilotsController(ServiceMock.Object);

            OkObjectResult message = (OkObjectResult)controller.Get().Result;

            Assert.Equal(200, message.StatusCode.Value);
        }
        public void GET_WhenGetItem_ThenServiceReturnOkAndThisObject()
        {
            //Arrange
            var id = Guid.NewGuid();

            var fakeService = A.Fake <IPilotService>();

            A.CallTo(() => fakeService.Get(id)).Returns(new PilotDto());

            var controller = new PilotsController(fakeService);

            //Act
            var response = controller.Get(id) as ObjectResult;

            //Assert
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode);
            Assert.IsInstanceOf(typeof(PilotDto), response.Value);
        }