public async Task ListFunctionsAsync_WithNoInputs_ReturnsList() { // Arrange var functionService = Substitute.For <IFunctionService>(); var inList = new List <FunctionModel>(); inList.Add(new FunctionModel { Name = "Test Functions 1", Id = Guid.NewGuid() }); inList.Add(new FunctionModel { Name = "Test Functions 2", Id = Guid.NewGuid() }); inList.Add(new FunctionModel { Name = "Test Functions 3", Id = Guid.NewGuid() }); PaginatedResult <FunctionModel> paginatedResult = new PaginatedResult <FunctionModel> { CurrentPage = 1, PageCount = 1, PageSize = 3, Results = inList }; functionService.GetPaginatedListAsync(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <List <KeyValuePair <string, string> > >()).Returns(paginatedResult); var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); // Act IActionResult actionResult = await controller.ListFunctionsAsync(1, 10, true, string.Empty, string.Empty); // Assert var okResult = actionResult as OkObjectResult; Assert.NotNull(okResult); var outList = okResult.Value as List <Function>; Assert.NotNull(outList); for (var i = 0; i < outList.Count; i++) { Assert.Equal(outList[i].Uuid, inList[i].Id); Assert.Equal(outList[i].Name, inList[i].Name); } }
public async Task ListFunctionsAsync_WithNoInputs_ReturnsList() { // Arrange var functionService = Substitute.For <IFunctionService>(); var inList = new List <Function>(); inList.Add(new Function { Name = "Test Functions 1", Uuid = Guid.NewGuid() }); inList.Add(new Function { Name = "Test Functions 2", Uuid = Guid.NewGuid() }); inList.Add(new Function { Name = "Test Functions 3", Uuid = Guid.NewGuid() }); functionService.GetListAsync().Returns(inList); var controller = new FunctionController(functionService); // Act IActionResult actionResult = await controller.ListFunctionsAsync(false, 0, 50, string.Empty, null); // Assert var okResult = actionResult as OkObjectResult; Assert.NotNull(okResult); var outList = okResult.Value as List <Function>; Assert.NotNull(outList); for (var i = 0; i < outList.Count; i++) { Assert.Equal(outList[i].Uuid, inList[i].Uuid); Assert.Equal(outList[i].Name, inList[i].Name); } }