public async Task <BeContract> FindBeContractByIdAsync(string id)
        {
            BeContract contract = null;
            await Task.Run(() => contract = BeContractsMock.GetContracts().FirstOrDefault(c => c.Id.Equals(id)));

            return(contract);
        }
        public void TestDeserializeBeContractWithQuery()
        {
            var contractByJson = Validators.Generators.DeserializeBeContract(GetAddressByDogIdString());
            var contract       = BeContractsMock.GetAddressByDogId();

            BeContractEquals.AreEquals(contract, contractByJson);
        }
        public void TestValidateBeContractCallWithEmptyInputNotRequiredWorking()
        {
            var contract   = BeContractsMock.GetDoubleInputContract();
            var callString = @"{
            'Id': 'DoubleInputContract',
            'ISName': 'Test man',
	        'Inputs': {
                    'First': 1090
                }
            }";
            var call       = GetBeContractCall(callString);

            Validators.ValidateBeContractCall(contract, call);
        }
        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);
        }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        public async Task TestValidateBeContractWithDuplicatedInputsFailAsync()
        {
            var contract = BeContractsMock.GetMathemathicFunction();

            contract.Inputs[0].Key = "B";
            try
            {
                await Validators.ValidateBeContract(contract);
            }
            catch (BeContractException ex)
            {
                var exc = new BeContractException("Duplicated key in GetMathemathicFunction contract for Inputs B, B");
                Assert.AreEqual(ex.Message, exc.Message);
            }
        }
Beispiel #7
0
        public async Task TestValidateBeContractWithoutQueryMappingContractKeyFail()
        {
            try
            {
                var contract = BeContractsMock.GetAddressByDogId();
                contract.Queries[0].Mappings[0].LookupInputKey = null;

                await Validators.ValidateBeContract(contract);

                Assert.Fail("Contract should not be valid without an query mapping contractkey");
            }
            catch (BeContractException ex)
            {
                Console.WriteLine(ex);
            }
        }
Beispiel #8
0
        public async Task TestValidateBeContractWithQueryContractFail()
        {
            try
            {
                var contract = BeContractsMock.GetAddressByDogId();
                contract.Queries[0].Contract = null;

                await Validators.ValidateBeContract(contract);

                Assert.Fail("Contract should not be valid without an query contract");
            }
            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);
            }
        }
 public BeContract CreateGoodContract()
 {
     return(BeContractsMock.GetOwnerIdByDogId());
 }
        public void TestSerializeBeContractWithQuery()
        {
            var json = Validators.Generators.SerializeBeContract(BeContractsMock.GetAddressByDogId());

            TestSerializedJson(GetAddressByDogIdString(), json);
        }
Beispiel #15
0
        public async Task TestValidateBeContractWithDuplicatedInputsSuccess()
        {
            var contract = BeContractsMock.GetMathemathicFunction();

            Assert.IsTrue(await Validators.ValidateBeContract(contract));
        }
Beispiel #16
0
 public async Task TestValidateBeContractWithQueryMappingLookupInputKeySuccess()
 {
     var contract = BeContractsMock.GetAddressByDogId();
     await Validators.ValidateBeContract(contract);
 }