public async Task If_network_is_down_cant_register_trader() { mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.RegistrationUrl, It.IsAny <String>())) .ThrowsAsync(new HttpRequestException()); BlockchainClient.Result error = await clientWithMock.RegisterNewTrader(new User()); Assert.AreEqual(error, BlockchainClient.Result.NETWORK); }
public async Task send_property_return_false_when_user_already_exist() { mockBlockService.Setup(m => m.InvokeHead(It.IsAny <String>(), It.IsAny <String>())) .ReturnsAsync(false); BlockchainClient.Result error = await clientWithMock.SendProperty(new Transaction()); Assert.AreEqual(BlockchainClient.Result.EXISTERROR, error); }
public async Task If_PropertyId_and_description_is_null_return_Empty() { Property property = new Property(); mockBlockService.Setup(m => m.InvokePost(HyperledgerConsts.PropertyUrl, It.IsAny <String>())) .ThrowsAsync(new HttpRequestException()); BlockchainClient.Result error = await clientWithMock.RegisterNewProperty(property); Assert.AreEqual(BlockchainClient.Result.EMPTY, error); }
public async Task cant_register_new_property_if_it_exist() { Property property = new Property(); property.PropertyId = "123"; property.description = "456"; mockBlockService.Setup(m => m.InvokeHead(It.IsAny <String>(), It.IsAny <String>())) .ReturnsAsync(true); BlockchainClient.Result error = await clientWithMock.RegisterNewProperty(property); Assert.AreEqual(BlockchainClient.Result.EXISTERROR, error); }
public async Task If_network_is_down_cant_register_properties() { Property property = new Property(); property.PropertyId = "123"; property.description = "456"; mockBlockService.Setup(m => m.InvokePost(HyperledgerConsts.PropertyUrl, It.IsAny <String>())) .ThrowsAsync(new HttpRequestException()); BlockchainClient.Result error = await clientWithMock.RegisterNewProperty(property); Assert.AreEqual(BlockchainClient.Result.NETWORK, error); }
public async Task If_network_is_down_sendProperty_return_false() { mockBlockService.Setup(m => m.InvokeHead(HyperledgerConsts.TraderUrl, TestJsonObjectConsts.trader1ID)) .ReturnsAsync(true); mockBlockService.Setup(m => m.InvokePost(It.IsAny <String>(), It.IsAny <String>())) .ThrowsAsync(new HttpRequestException()); BlockchainClient.Result error = await clientWithMock.SendProperty(new Transaction() { newOwner = TestJsonObjectConsts.trader1ID }); Assert.AreEqual(BlockchainClient.Result.NETWORK, error); }
public async Task CreatePackagesEnterUnExistingReceipient() { CreatePackage package = new CreatePackage() { packageId = "testId", sender = "sender", recipient = "recipient" }; mockBlockService.Setup(m => m.InvokeHead(It.IsAny <String>(), It.IsAny <String>())) .ReturnsAsync(false); BlockchainClient.Result notExist = await clientWithMock.CreatePackage(package); Assert.AreEqual(notExist, BlockchainClient.Result.EXISTERROR); }
public async Task CreatePackageNetworkDown() { CreatePackage package = new CreatePackage() { packageId = "testId", sender = "sender", recipient = "recipient" }; mockBlockService.Setup(m => m.InvokeHead(HyperledgerConsts.TraderUrl, It.IsAny <String>())) .ReturnsAsync(true); mockBlockService.Setup(m => m.InvokePost(HyperledgerConsts.CreatePackageUrl, It.IsAny <String>())) .ThrowsAsync(new HttpRequestException()); BlockchainClient.Result networkError = await clientWithMock.CreatePackage(package); Assert.AreEqual(BlockchainClient.Result.NETWORK, networkError); }