public async Task GetAllPlatforms_Valid() { // Arrange IEnumerable <PlatformModel> expected = GetSampleData(); _mockPlatformsService.RetrieveAllAsync().Returns(expected); // Act ActionResult <IEnumerable <PlatformModel> > response = await _sut.GetAllPlatforms(); // Assert await _mockPlatformsService.Received(1).RetrieveAllAsync(); var createdAtActionResult = Assert.IsType <OkObjectResult>(response.Result); IEnumerable <PlatformModel> actual = (IEnumerable <PlatformModel>)createdAtActionResult.Value; Assert.True(actual is not null); Assert.Equal(expected.Count(), actual.Count()); for (int i = 0; i < expected.Count(); i++) { Assert.Equal(expected.ElementAt(i).PlatformId, actual.ElementAt(i).PlatformId); Assert.Equal(expected.ElementAt(i).PlatformName, actual.ElementAt(i).PlatformName); } }
public async Task <ActionResult <IEnumerable <PlatformModel> > > GetAllPlatforms() { IEnumerable <PlatformModel> platforms = await _platformsService.RetrieveAllAsync(); return(Ok(platforms)); }