Exemplo n.º 1
0
        public void GetWorker_WhenCalled_ReturnsAllItems()
        {
            int calls = 0;

            service.Setup(x => x.GetAll())
            .Returns(() => serviceUsers);

            mapper.Setup(m => m.Map <WorkerControllerModel>(It.IsAny <WorkerServiceModel>()))
            .Returns(() => controllersUsers[calls])
            .Callback(() => calls++);

            // Act
            var result = usersController.GetWorker();

            // Assert
            var allNumbers = new List <WorkerControllerModel>(result);

            for (int i = 0; i < 3; i++)
            {
                Assert.True(allNumbers[i] == controllersUsers[i]);
            }
        }
Exemplo n.º 2
0
        public void GetRegistrated_WhenCalled_ReturnsInternalError(int id)
        {
            // Arrange
            usersController = new WorkersController(null, null, log.Object);

            // Act
            var result = usersController.GetWorker(id);

            // Assert
            var response = result as StatusCodeResult;

            Assert.Equal(500, response.StatusCode);
        }