Пример #1
0
        public void AddItemToEndedPath()
        {
            IWeaverPath p = NewPath();

            p.AddItem(new PathEnder());
            WeaverTestUtil.CheckThrows <WeaverPathException>(true, () => p.AddItem(new Candy()));
        }
Пример #2
0
        /*--------------------------------------------------------------------------------------------*/
        public override string BuildParameterizedString(IWeaverPath pPath)
        {
            //TODO: WeaverStatementRemoveProperty: use query parameter
            var propName = WrapException(() => pPath.Config.GetPropertyDbName(vProp));

            return("it.removeProperty('" + propName + "')");
        }
Пример #3
0
        public void PathFromIndexBounds(int pIndex, bool pInclusive, bool pThrows)
        {
            IWeaverPath p = NewPath(3);

            WeaverTestUtil.CheckThrows <WeaverPathException>(pThrows,
                                                             () => p.PathFromIndex(pIndex, pInclusive)
                                                             );
        }
Пример #4
0
        public void ItemAtIndexBounds(int pIndex)
        {
            IWeaverPath p = NewPath(3);

            WeaverTestUtil.CheckThrows <WeaverPathException>(true,
                                                             () => p.ItemAtIndex(pIndex)
                                                             );
        }
Пример #5
0
        /*--------------------------------------------------------------------------------------------*/
        public override string BuildParameterizedString(IWeaverPath pPath)
        {
            //TODO: WeaverStatementSetProperty: use query parameter
            var propName = WrapException(() => pPath.Config.GetPropertyDbName(vProp));
            var valParam = pPath.Query.AddParam(new WeaverQueryVal(vValue));

            return("it.setProperty('" + propName + "'," + valParam + ")");
        }
Пример #6
0
        public void AddItem()
        {
            IWeaverPath p = NewPath();

            var candy = new Candy();

            p.AddItem(candy);

            Assert.AreEqual(1, p.Length, "Incorrect Length.");
            Assert.AreEqual(candy, p.ItemAtIndex(0), "Incorrect item at index 0.");
        }
Пример #7
0
        public void PathToIndex(int pIndex, bool pInclusive, int pCount)
        {
            IWeaverPath p = NewPath(5);

            IList <IWeaverPathItem> result = p.PathToIndex(pIndex, pInclusive);

            Assert.NotNull(result, "Result should be filled.");
            Assert.AreEqual(pCount, result.Count, "Incorrect Result.Count.");
            Assert.AreEqual(p.ItemAtIndex(0), result[0], "Incorrect Result[0].");

            int ri = pCount - 1;

            Assert.AreEqual(p.ItemAtIndex(ri), result[ri], "Incorrect Result[" + ri + "].");
        }
Пример #8
0
        public void BuildParameterizedScript()
        {
            var i0 = new WeaverStepCustom("first()");
            var i1 = new WeaverStepCustom("second");
            var i2 = new WeaverStepCustom("[0..10]", true);
            var i3 = new PathEnder();

            IWeaverPath p = NewPath();

            p.AddItem(i0);
            p.AddItem(i1);
            p.AddItem(i2);
            p.AddItem(i3);

            const string expect = "first().second[0..10].ender";

            Assert.AreEqual(expect, p.BuildParameterizedScript(), "Incorrect result.");
        }
Пример #9
0
        public void ItemAtIndex()
        {
            var i0 = new Root();
            var i1 = new Person();
            var i2 = new PersonLikesCandy();
            var i3 = new Candy();

            IWeaverPath p = NewPath();

            p.AddItem(i0);
            p.AddItem(i1);
            p.AddItem(i2);
            p.AddItem(i3);

            Assert.AreEqual(4, p.Length, "Incorrect Length.");
            Assert.AreEqual(i0, p.ItemAtIndex(0), "Incorrect item at index 0.");
            Assert.AreEqual(i1, p.ItemAtIndex(1), "Incorrect item at index 1.");
            Assert.AreEqual(i2, p.ItemAtIndex(2), "Incorrect item at index 2.");
            Assert.AreEqual(i3, p.ItemAtIndex(3), "Incorrect item at index 3.");
        }
Пример #10
0
        public void IndexOfItem()
        {
            var i0 = new Root();
            var i1 = new Person();
            var i2 = new PersonLikesCandy();
            var i3 = new Candy();

            IWeaverPath p = NewPath();

            p.AddItem(i0);
            p.AddItem(i1);
            p.AddItem(i2);
            p.AddItem(i3);

            Assert.AreEqual(4, p.Length, "Incorrect Path.Length.");
            Assert.AreEqual(0, p.IndexOfItem(i0), "Incorrect item index at 0.");
            Assert.AreEqual(1, p.IndexOfItem(i1), "Incorrect item index at 1.");
            Assert.AreEqual(2, p.IndexOfItem(i2), "Incorrect item index at 2.");
            Assert.AreEqual(3, p.IndexOfItem(i3), "Incorrect item index at 3.");
        }
Пример #11
0
        public void Length(int pLen)
        {
            IWeaverPath p = NewPath(pLen);

            Assert.AreEqual(pLen, p.Length, "Incorrect Length.");
        }
Пример #12
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public abstract string BuildParameterizedString(IWeaverPath pPath);
Пример #13
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public WeaverPathException(IWeaverPath pPath, string pMessage) : base(pMessage)
 {
     Path = pPath;
 }