Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }