public void TestValidateBeContractReturnWithAllWorking() { var contract = BeContractsMock.GetAddressByOwnerId(); var callString = @"{ 'Id': 'GetAddressByOwnerId', 'Outputs': { 'Street': 'Vandernoot', 'StreetNumber': 10, 'Country': 'Bxl' } }"; var call = GetBeContractReturn(callString); Validators.ValidateBeContractReturn(contract, call); }
public async Task TestValidateBeContractWithoutInputTypeFail() { try { var contract = BeContractsMock.GetAddressByOwnerId(); contract.Inputs[0].Type = null; await Validators.ValidateBeContract(contract); Assert.Fail("Contract should not be valid without an input type"); } catch (BeContractException ex) { Console.WriteLine(ex); } }
public void TestValidateBeContractCallWithOutputKeyNotFoundFail() { var contract = BeContractsMock.GetAddressByOwnerId(); var callString = @"{ 'Id': 'GetAddressByOwnerId', 'Outputs': { 'Street': 'Vandernoot', 'Country': 'Bxl' } }"; try { var call = GetBeContractReturn(callString); Validators.ValidateBeContractReturn(contract, call); Assert.Fail("Ouput missing a key, must throw an exception"); } catch (BeContractException ex) { Assert.AreEqual("No key was found for StreetNumber", ex.Message); } }
public void TestValidateBeContractCallWithOutputEmptyIdFail() { var contract = BeContractsMock.GetAddressByOwnerId(); var callString = @"{ 'Outputs': { 'Street': 'Vandernoot', 'StreetNumber': 10, 'Country': 'Bxl' } }"; try { var call = GetBeContractReturn(callString); Validators.ValidateBeContractReturn(contract, call); Assert.Fail("An empty output id, must throw an exception"); } catch (BeContractException ex) { Console.WriteLine(ex); } }
public void TestValidateBeContractCallWithOutputNotSameTypeFail() { var contract = BeContractsMock.GetAddressByOwnerId(); var callString = @"{ 'Id': 'GetAddressByOwnerId', 'ISName': 'Test man', 'Outputs': { 'Street': 'Vandernoot', 'StreetNumber': '10', 'Country': 'Bxl' } }"; try { var call = GetBeContractReturn(callString); Validators.ValidateBeContractReturn(contract, call); Assert.Fail("Ouput don't have the same type, must throw an exception"); } catch (BeContractException ex) { Assert.AreEqual($"The contract expects Int32 but String was found", ex.Message); } }
public void TestValidateBeContractCallWithOutputNotSameIdFail() { var contract = BeContractsMock.GetAddressByOwnerId(); var callString = @"{ 'Id': 'GetAddressByOwner', 'ISName': 'Test man', 'Outputs': { 'Street': 'Vandernoot', 'StreetNumber': 10, 'Country': 'Bxl' } }"; try { var call = GetBeContractReturn(callString); Validators.ValidateBeContractReturn(contract, call); Assert.Fail("Contract's do not have the same ID, must throw an exception"); } catch (BeContractException ex) { Assert.AreEqual("Contract's do not have the same ID", ex.Message); } }