コード例 #1
0
        public void AreAllElementsInMessageContainedInContractShouldReturnValidContract()
        {
            var contractDictionary = new CaseInsensitiveDictionary <SchemaObject>
            {
                { "Name", new SchemaObject
                  {
                      Type = "String"
                  } },
                { "Age", new SchemaObject
                  {
                      Type = "Integer"
                  } }
            };

            var messageKeyDictionary = new CaseInsensitiveDictionary <object>
            {
                { "Name", "Robert" },
                { "Age", "31" }
            };

            var testService = new TesterService();

            var result = testService.AreAllElementsInMessageContainedInContract(messageKeyDictionary, contractDictionary);

            result.IsMessageValid.ShouldBeTrue();
        }
コード例 #2
0
        public void AreAllElementsInMessageContainedInContractShouldReturnInvalidContract()
        {
            var contractDictionary = new CaseInsensitiveDictionary <SchemaObject>
            {
                { "Name", new SchemaObject
                  {
                      Type = "String"
                  } }
            };

            var messageKeyDictionary = new CaseInsensitiveDictionary <object>
            {
                { "Name", "Robert" },
                { "Age", "31" }
            };

            var testService = new TesterService();

            var result = testService.AreAllElementsInMessageContainedInContract(messageKeyDictionary, contractDictionary);

            result.IsMessageValid.ShouldBeFalse("Message property \"Age\" is not part of the contract.");
        }