public async void GetProjectDataModelById_ReturnsProjectDataModel() { _projectDataModelService.Setup(s => s.GetProjectDataModelById(It.IsAny <int>(), It.IsAny <CancellationToken>())) .ReturnsAsync((int id, CancellationToken cancellationToken) => new ProjectDataModel { Id = id, Name = "Product" }); var controller = new ProjectDataModelController(_projectDataModelService.Object, _mapper, _logger.Object); var result = await controller.GetProjectDataModel(1, 1); var okActionResult = Assert.IsType <OkObjectResult>(result); var returnValue = Assert.IsType <ProjectDataModelDto>(okActionResult.Value); Assert.Equal(1, returnValue.Id); }
public async void GetProjectDataModelByName_ReturnsProjectDataModel() { _projectDataModelService.Setup(s => s.GetProjectDataModelByName(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync((int projectId, string name, CancellationToken cancellationToken) => new ProjectDataModel { Id = 1, Name = name, ProjectId = projectId }); var controller = new ProjectDataModelController(_projectDataModelService.Object, _mapper, _logger.Object); var result = await controller.GetProjectDataModel(1, "Product"); var okActionResult = Assert.IsType <OkObjectResult>(result); var returnValue = Assert.IsType <ProjectDataModelDto>(okActionResult.Value); Assert.Equal("Product", returnValue.Name); Assert.Equal(1, returnValue.ProjectId); }