public async Task PropertyHistoryWillReturnListOfTransfersInOrderWithMostRecentFirst() { string property = "Property A"; string package = "PackageA"; mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.PackageHistoryUrl(Uri.EscapeDataString(package)))) .ReturnsAsync("[{\"timestamp\":\"2018-04-21T19:47:54.368Z\"},{\"timestamp\":\"2018-04-21T19:48:54.368Z\"}]"); mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.PropertyPackageUrl(Uri.EscapeDataString(property)))) .ReturnsAsync("[{\"PackageId\": \"PackageA\"}]"); List <NewTransfer> results = await clientWithMock.GetPropertyHistory(property); for (int i = 0; i < results.Count() - 1; i++) { Assert.IsTrue(results[i].timestamp > results[i + 1].timestamp); } }
public async Task PropertyHistoryWillCallPackageHistoryOnEveryReturnedPackage() { string property = "Property A"; string packageList = "[{\"PackageId\": \"PackageA\"}, {\"PackageId\": \"PackageB\"}]"; List <Package> actualList = JsonConvert.DeserializeObject <List <Package> >(packageList); mockBlockService.Setup(m => m.InvokeGet(It.IsAny <String>())) .ReturnsAsync("[]"); mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.PropertyPackageUrl(Uri.EscapeDataString(property)))) .ReturnsAsync(packageList); await clientWithMock.GetPropertyHistory(property); foreach (Package package in actualList) { mockBlockService.Verify(m => m.InvokeGet(HyperledgerConsts.PackageHistoryUrl(package.PackageId))); } }