public async Task GetInventory_WhenServiceListsMultiplePages_ShouldContainAllObjects() { var squareClient = this.GivenSquareClientCatalogApiReturnsData(); var subject = new SquareProductService(NullLogger <SquareTransactionService> .Instance, squareClient); var catalogObjects = await subject.GetAllProductsAsync(); catalogObjects.Should().HaveCount(2); catalogObjects[0].ProductCode.Should().Be("ID-1"); catalogObjects[0].ProductName.Should().Be("Item1 (Regular)"); catalogObjects[1].ProductCode.Should().Be("ID-2"); catalogObjects[1].ProductName.Should().Be("Item2 (Regular)"); }
public void GetInventory_WhenRequestIsCancelled_ShouldThrowException() { var squareClient = this.GivenSquareClientCatalogApiWaitsToContinue(out var waitHandle); var cts = new CancellationTokenSource(); var subject = new SquareProductService(NullLogger <SquareTransactionService> .Instance, squareClient); var task = subject.GetAllProductsAsync(); cts.Cancel(); waitHandle.Set(); task.Awaiting(x => x).Should().ThrowAsync <TaskCanceledException>(); }