public async Task GetSortedBridgesReturnsSortedBridgesCollection() { // Arrange var options = new DbContextOptionsBuilder <GeojamDbContext>() .UseInMemoryDatabase(nameof(GetSortedBridgesReturnsSortedBridgesCollection)) .Options; var dbContext = new GeojamDbContext(options); GenerateDbContext(dbContext); var hikerProvider = new HikerProvider(dbContext, null, mapper); var bridgesProvider = new BridgesProvider(dbContext, null, mapper, hikerProvider, null); var bridges = await bridgesProvider.GetBridgesAsync(); // Act var actual = await bridgesProvider.GetSortedBridgesAsync(bridges.Bridges.ToArray()); Assert.True(actual.IsSuccess); Assert.Null(actual.ErrorMessage); Assert.True(actual.SortedBridges.Any()); Assert.Equal(actual.SortedBridges.Count(), dbContext.Bridges.Count()); for (int i = 1; i < actual.SortedBridges.Count; i++) { Assert.True(actual.SortedBridges.Keys[i - 1] <= actual.SortedBridges.Keys[i]); } }
public async Task GetBridgesReturnsAllBridges() { // Arrange var options = new DbContextOptionsBuilder <GeojamDbContext>() .UseInMemoryDatabase(nameof(GetBridgesReturnsAllBridges)) .Options; var dbContext = new GeojamDbContext(options); GenerateDbContext(dbContext); var hikerProvider = new HikerProvider(dbContext, null, mapper); var bridgesProvider = new BridgesProvider(dbContext, null, mapper, hikerProvider, null); // Act var actual = await bridgesProvider.GetBridgesAsync(); // Assert Assert.True(actual.IsSuccess); Assert.Null(actual.ErrorMessage); Assert.True(actual.Bridges.Any()); Assert.Equal(actual.Bridges.Count(), dbContext.Bridges.Count()); Assert.IsType <Models.Bridge>(actual.Bridges.First()); }