コード例 #1
0
        public void JsonMappingCompoundTo_Constructor_SetsProperties_NotIsCompound()
        {
            //------------Setup for test--------------------------
            // ReSharper disable RedundantArgumentName
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());

            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo { SourceName = "[[a]]", DestinationName = "a" }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
        }
コード例 #2
0
        public void JsonMappingCompoundTo_MaxCount_NotIsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
            dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[rec().a]]",
                    DestinationName = "myName"
                }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.MaxCount, 1);

            // check for list
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[rec(*).a]]",
                    DestinationName = "myName"
                }
            );
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.MaxCount, 2);
        }
コード例 #3
0
        private void CheckComplexEvaluatedResultIndexed(string expression, string name, int index, string expected, DsfDataObject dataObject)
        {
            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
            compound: new JsonMappingTo
                {
                    SourceName = expression,
                    DestinationName = name
                }
            );
            var a = jsonMappingCompound.ComplexEvaluatedResultIndexed(index);
            if (a is JProperty)
            {
                var jp = new JObject { a };
                Assert.AreEqual(expected, jp
                .ToString(Formatting.None));
            }
            else
            {
                var jp = new JProperty(name, jsonMappingCompound.ComplexEvaluatedResultIndexed(index));
                var j = new JObject(jp);
                var s = j.ToString(Formatting.None);
                Assert.AreEqual(expected,
                s);
            }

        }
コード例 #4
0
        public void JsonMappingCompoundTo_EvalResultIndexed_NotIsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
            dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
            //------------Execute Test---------------------------

            // for scalars
            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[a]]",
                    DestinationName = "myName"
                }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.EvaluatedResultIndexed(0), 10);
            Assert.AreEqual(jsonMappingCompound.EvaluatedResultIndexed(1), null);

            // for lists
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[rec(*).a]]",
                    DestinationName = "myName"
                }
            );
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(new JObject(new JProperty("a", jsonMappingCompound.EvaluatedResultIndexed(0))).ToString(Formatting.None), "{\"a\":[50,60]}");
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
            compound: new JsonMappingTo
                {
                    SourceName = "[[rec(*).b]]",
                    DestinationName = "myName"
                }
            );
            Assert.AreEqual(new JObject(new JProperty("b", jsonMappingCompound.EvaluatedResultIndexed(1))).ToString(Formatting.None), "{\"b\":[500,600]}");
        }
コード例 #5
0
        public void JsonMappingCompoundTo_EvalResultIndexed_IsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[a]],[[b]]",
                    DestinationName = "myName"
                }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsTrue(jsonMappingCompound.IsCompound);
        }