Example #1
0
        public void TranslateTest()
        {
            bool unicode = false;

            for (int i = 0; i < 2; i++)
            {
                using (P4MapApi target = new P4MapApi(unicode))
                {
                    String        left1  = "//depot/...";
                    String        right1 = "//ws/...";
                    P4MapApi.Type type1  = P4MapApi.Type.Include;
                    target.Insert(left1, right1, type1);

                    int tCount = target.Count;
                    Assert.AreEqual(1, tCount);

                    String actual = target.Translate("//ws/foo.txt", P4MapApi.Direction.RightLeft);
                    Assert.AreEqual(actual, "//depot/foo.txt");

                    actual = target.Translate("//depot/foo.txt", P4MapApi.Direction.LeftRight);
                    Assert.AreEqual(actual, "//ws/foo.txt");

                    actual = target.Translate("//usr/bar.txt", P4MapApi.Direction.LeftRight);
                    Assert.AreEqual(actual, null);

                    unicode = !unicode;
                }
            }
        }
Example #2
0
        public void InsertTest1()
        {
            bool unicode = false;

            for (int i = 0; i < 2; i++)
            {
                using (P4Server pserver = new P4Server(unicode))
                {
                    using (P4MapApi target = new P4MapApi(pserver))
                    {
                        string        lr1   = "Both 1";
                        P4MapApi.Type type1 = P4MapApi.Type.Include;
                        target.Insert(lr1, type1);

                        string        lr2   = "Both 2";
                        P4MapApi.Type type2 = P4MapApi.Type.Include;
                        target.Insert(lr2, type2);

                        int tCount = target.Count;
                        Assert.AreEqual(2, tCount);

                        // no errors so passed
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Adds a new entry in the map
 /// </summary>
 /// <param name="lr">String representing both the the left and right sides of
 /// the new entry</param>
 /// <param name="t">Type of the new entry</param>
 public void Insert(String lr, P4MapApi.Type t)
 {
     if (UseUnicode)
     {
         using (PinnedByteArray plr = MarshalStringToIntPtr(lr))
         {
             InsertW(pMapApi, plr, t);
         }
     }
     else
     {
         InsertA(pMapApi, lr, t);
     }
 }
Example #4
0
 /// <summary>
 /// Adds a new entry in the map
 /// </summary>
 /// <param name="left">String representing the the left side of the new entry</param>
 /// <param name="right">String representing the the right side of the new entry</param>
 /// <param name="type">Type of the new entry</param>
 public void Insert(String left, String right, P4MapApi.Type type)
 {
     if (UseUnicode)
     {
         using (PinnedByteArray pLeft = MarshalStringToIntPtr(left),
                pRight = MarshalStringToIntPtr(right))
         {
             InsertW(pMapApi, pLeft, pRight, type);
         }
     }
     else
     {
         InsertA(pMapApi, left, right, type);
     }
 }
Example #5
0
        public void GetLeftTest()
        {
            bool unicode = false;

            for (int i = 0; i < 2; i++)
            {
                using (P4MapApi target = new P4MapApi(unicode))
                {
                    string        left1  = "//depot/main/...";
                    string        right1 = "//XP1_usr/depot/main/...";
                    P4MapApi.Type type1  = P4MapApi.Type.Include;
                    target.Insert(left1, right1, type1);

                    string        left2  = "//depot/main/www/...";
                    string        right2 = "//XP1_usr/depot/main/www/...";
                    P4MapApi.Type type2  = P4MapApi.Type.Exclude;
                    target.Insert(left2, right2, type2);


                    string        left3  = "//depot/dev/script/...";
                    string        right3 = "//XP1_usr/depot/dev/script/...";
                    P4MapApi.Type type3  = P4MapApi.Type.Include;
                    target.Insert(left3, right3, type3);


                    string        left4  = "//depot/main/www/...";
                    string        right4 = "//XP1_usr/depot/live/www/*.html";
                    P4MapApi.Type type4  = P4MapApi.Type.Include;
                    target.Insert(left4, right4, type4);

                    int tCount = target.Count;
                    Assert.AreEqual(4, tCount);

                    String actual = target.GetLeft(1);
                    Assert.AreEqual(left2, actual);

                    actual = target.GetLeft(0);
                    Assert.AreEqual(left1, actual);

                    unicode = !unicode;
                }
            }
        }
Example #6
0
        public void JoinTest()
        {
            bool unicode = false;

            for (int i = 0; i < 2; i++)
            {
                using (P4MapApi target1 = new P4MapApi(unicode))
                {
                    String        left1  = "//depot/...";
                    String        right1 = "//ws/...";
                    P4MapApi.Type type1  = P4MapApi.Type.Include;
                    target1.Insert(left1, right1, type1);

                    int tCount1 = target1.Count;
                    Assert.AreEqual(1, tCount1);

                    using (P4MapApi target2 = new P4MapApi(unicode))
                    {
                        String        left2  = "//ws/...";
                        String        right2 = "//ace/...";
                        P4MapApi.Type type2  = P4MapApi.Type.Include;
                        target2.Insert(left2, right2, type2);

                        int tCount2 = target2.Count;
                        Assert.AreEqual(1, tCount2);

                        using (P4MapApi actual = P4MapApi.Join(target1, P4MapApi.Direction.LeftRight, target2, P4MapApi.Direction.LeftRight))
                        {
                            int tCount3 = actual.Count;
                            Assert.AreEqual(1, tCount3);

                            string translated = actual.Translate("//depot/foo.txt", P4MapApi.Direction.LeftRight);
                            Assert.AreEqual(translated, "//ace/foo.txt");

                            unicode = !unicode;
                        }
                    }
                }
            }
        }
Example #7
0
 private static extern void InsertW(IntPtr pMap, IntPtr l,
                                    IntPtr r, P4MapApi.Type t);
Example #8
0
 private static extern void InsertA(IntPtr pMap, String l,
                                    String r, P4MapApi.Type t);