public static void TestIntersectWithRest()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                "I"
            };
            IEnumerable <string> stringsList = new List <string>()
            {
                "W", "a", "f", "U"
            };
            Strings stringsReturn     = new Strings();
            Strings stringsTestReturn = new Strings
            {
                "a",
                "E",
                "f",
                "I",
                "Y"
            };

            strings.IntersectWith(stringsList, stringsReturn);

            Assert.AreEqual(stringsTestReturn.ToString(), stringsReturn.ToString());
            Assert.AreEqual("W,U", strings.ToString());
        }
        public static void TestNoIntersectWithRest()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                { "Y", 3 }
            };
            IEnumerable <string> stringsList = new List <string>()
            {
                "h", "J", "a", "b"
            };
            Strings stringsReturn     = new Strings();
            Strings stringsTestReturn = new Strings
            {
                "a",
                "b",
                "E",
                "h",
                "J",
                "W",
                "Y"
            };

            strings.IntersectWith(stringsList, stringsReturn);

            Assert.AreEqual(stringsTestReturn.ToString(), stringsReturn.ToString());
            Assert.AreEqual(0, strings.Count);
        }
        public static void TestAddRangeOrderableStrings()
        {
            OrderableStrings string1 = new OrderableStrings
            {
                { "W", -4 },
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                { "I", -3 },
                { "A", 6 }
            };

            OrderableStrings string2 = new OrderableStrings
            {
                "W",
                "E",
                "Y",
                "U",
                "I"
            };

            string2.AddRange(string1);

            Assert.AreEqual(6, string2.Count);
            Assert.AreEqual(-4, string2.GetOrderNumber(0));
            Assert.AreEqual(-1, string2.GetOrderNumber(1));
            Assert.AreEqual(3, string2.GetOrderNumber(2));
            Assert.AreEqual(0, string2.GetOrderNumber(3));
            Assert.AreEqual(-3, string2.GetOrderNumber(4));
        }
        public static void TestJoinStringsSeparatorPrefix()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LLA",
                "YA",
                { "UT", -3 }
            };

            Assert.AreEqual("HLLA-HYA-HUT", strings.JoinStrings("-", "H"));
        }
        public static void TestJoinSeparator()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LLA",
                "YA",
                { "UT", -3 }
            };

            Assert.AreEqual("LLA-YA-UT", strings.JoinStrings("-"));
        }
        public static void TestRemoveBetween()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "U", 0 },
                "I"
            };

            Assert.True(strings.Remove("U"));
            Assert.AreEqual("W,I", strings.ToString());
        }
        public static void TestContainsReturnNoOrder()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "u",
                { "h", -1 }
            };

            Assert.True(strings.Contains("u"));
            Assert.True(strings.Contains("h"));
            Assert.False(strings.Contains("w"));
        }
        public static void TestClear()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LLA",
                "YA",
                { "UT", -3 }
            };

            strings.Clear();

            Assert.AreEqual(0, strings.Count);
        }
        public static void TestInsert()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LLA",
                "YA",
                { "UT", -3 }
            };

            strings.Insert(2, "test-insert");

            Assert.AreEqual("LLA,YA,test-insert,UT", strings.ToString());
        }
        public static void TestIndexOf()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                "E",
                "O"
            };

            Assert.AreEqual(1, strings.IndexOf("E"));
            Assert.AreEqual(2, strings.IndexOf("O"));
            Assert.AreEqual(0, strings.IndexOf("W"));
        }
        public static void TestRemoveAt()
        {
            OrderableStrings strings = new OrderableStrings
            {
                { "W", -4 },
                { "E", -1 },
            };

            strings.RemoveAt(1);

            Assert.AreEqual("W", strings.ToString());
            Assert.AreEqual(-4, strings.GetOrderNumber(0));
        }
        public static void TestInsertPrefix()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LLA",
                "YA",
                { "UT", -3 }
            };

            strings.InsertPrefix("H");

            Assert.AreEqual("HLLA,HYA,HUT", strings.ToString());
        }
        public static void TestInsertSuffixOnlyIfAbsent()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LLA",
                "YA",
                { "UT", -3 }
            };

            strings.InsertSuffix("A", true);

            Assert.AreEqual("LLA,YA,UTA", strings.ToString());
        }
        public static void TestInsertPrefixSuffix()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LL",
                "Y",
                { "UT", -3 }
            };

            strings.InsertPrefixSuffix("A", "O");

            Assert.AreEqual("ALLO,AYO,AUTO", strings.ToString());
        }
        public static void TestInsertSuffix()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "LL",
                "Y",
                { "UT", -3 }
            };

            strings.InsertSuffix("A");

            Assert.AreEqual("LLA,YA,UTA", strings.ToString());
        }
        public static void TestToLower()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                "O"
            };

            strings.ToLower();

            Assert.AreEqual("w,e,o", strings.ToString());
        }
        public static void TestStableSortWithNoOrder()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "b",
                "c",
                "a",
                "d"
            };

            strings.StableSort();

            Assert.AreEqual("b,c,a,d", strings.ToString());
        }
        public static void TestRemoveLast()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                "I"
            };

            Assert.True(strings.Remove("I"));
            Assert.AreEqual("W,E,Y,U", strings.ToString());
        }
        public static void TestRemoveNotInclude()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                "I"
            };

            Assert.False(strings.Remove("o"));
            Assert.AreEqual("W,E,Y,U,I", strings.ToString());
        }
Beispiel #20
0
        private OrderableStrings GetDependenciesOutputFilesProjectRelative(Project.Configuration conf, FileInfo projectFileInfo)
        {
            // Build list of dependencies output files relative to project file.
            OrderableStrings dependencyFiles = new OrderableStrings();

            foreach (Project.Configuration dependencyConf in conf.ResolvedDependencies)
            {
                var outputFileProjectRelative = Path.Combine(GetOutputDirectory(dependencyConf, projectFileInfo), FormatOutputFileName(dependencyConf));
                dependencyFiles.Add(outputFileProjectRelative, dependencyConf.TargetFileOrderNumber);
            }
            dependencyFiles.Sort();

            return(dependencyFiles);
        }
        public static void TestCopyTo()
        {
            OrderableStrings strings = new OrderableStrings
            {
                { "W", -4 },
                { "E", -1 },
            };

            string[] returnArray = new string[2];

            strings.CopyTo(returnArray, 0);

            Assert.AreEqual(new[] { "W", "E" }, returnArray);
        }
        public static void TestAddStringIntError()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "A",
                { "Y", -1 }
            };

            strings.Add("W", -4);
            strings.Add("A", -4);
            strings.Add("E", 1);
            strings.Add("B", 0);

            Assert.Throws <Sharpmake.Error>(() => strings.Add("Y", -2));
        }
        public static void TestAddStringTab()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "A",
                "Y"
            };

            string[] stringTab = { "W", "E" };

            strings.Add(stringTab);

            Assert.AreEqual(4, strings.Count);
            Assert.AreEqual("A,Y,W,E", strings.ToString());
        }
        public static void TestRemoveAtIndex()
        {
            OrderableStrings strings = new OrderableStrings
            {
                { "W", -4 },
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                { "I", -3 },
                { "A", 6 }
            };

            Assert.AreEqual(0, strings.SetOrRemoveAtIndex(0, "H"));
            Assert.AreEqual(3, strings.SetOrRemoveAtIndex(4, "H"));
            Assert.AreEqual("H,E,Y,U,A", strings.ToString());
        }
        public static void TestSetAtIndexSameValue()
        {
            OrderableStrings strings = new OrderableStrings
            {
                { "W", -4 },
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                { "I", -3 },
                { "A", 6 }
            };

            Assert.AreEqual("W,E,Y,U,I,A", strings.ToString());
            Assert.AreEqual(0, strings.SetOrRemoveAtIndex(0, "W"));
            Assert.AreEqual(-4, strings.GetOrderNumber(0));
        }
        public static void TestAddRangeOrderableStringsError()
        {
            OrderableStrings string1 = new OrderableStrings
            {
                { "W", -4 },
                { "E", -1 }
            };

            OrderableStrings string2 = new OrderableStrings
            {
                { "W", -3 },
                "E"
            };

            Assert.Throws <Sharpmake.Error>(() => string2.AddRange(string1));
        }
Beispiel #27
0
        public static void TestStableSortWithNoOrder()
        {
            OrderableStrings strings = new OrderableStrings();

            strings.Add("b");
            strings.Add("c");
            strings.Add("a");
            strings.Add("d");

            strings.StableSort();

            // Verify order is the expected one
            Assert.AreEqual(strings[0], "b");
            Assert.AreEqual(strings[1], "c");
            Assert.AreEqual(strings[2], "a");
            Assert.AreEqual(strings[3], "d");
        }
        public static void TestNoIntersectWith()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                { "Y", 3 }
            };
            IEnumerable <string> stringsList = new List <string>()
            {
                "h", "J", "a", "b"
            };

            strings.IntersectWith(stringsList);

            Assert.AreEqual(0, strings.Count);
        }
        public static void TestAddRangeIEnumerable()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "W"
            };

            IEnumerable <string> stringsList = new List <string>()
            {
                "h", "J"
            };

            strings.AddRange(stringsList);

            Assert.AreEqual(3, strings.Count);
            Assert.AreEqual("W,h,J", strings.ToString());
        }
        public static void TestRemoveRangeAllElements()
        {
            IEnumerable <string> stringsList = new List <string>()
            {
                "I", "Y", "E", "U", "W"
            };
            OrderableStrings strings = new OrderableStrings
            {
                "W",
                { "E", -1 },
                { "Y", 3 },
                { "U", 0 },
                "I"
            };

            strings.RemoveRange(stringsList);

            Assert.AreEqual(0, strings.Count);
        }