Beispiel #1
0
        public void BasicTest2()
        {
            object[] arr1 = { 1, 2, 2, 3, 4 },
            arr2  = { 2, 1, 2, 4, 3 },
            arr3  = { 1, 1, 2 },
            arr4  = { 4, 3, 2, 1, 1 },
            arr5  = { 1, 2, 2, 3 },
            arr6  = { 3, 3, 2, 1 },
            arr7  = { 1, 2 },
            arr8  = { "1", 2 },
            arr9  = { 5, '3', 1, 2, 4 },
            arr10 = { 2, 4, 5, "3", 1 },
            arr11 = { 1, 2, 3, 4, 5 },
            arr12 = { 5, '4', 3, "2", 1 },
            arr13 = { '3', '5', '4', "1", 2 },
            arr14 = { "1", 2, '3', '4', '5' },
            arr15 = { };

            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(arr1, arr2),
                            "Should return true with [1, 2, 2, 3, 4] and [2, 1, 2, 4, 3]");

            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(arr2, arr1),
                            "Should return true with [2, 1, 2, 4, 3] and [1, 2, 2, 3, 4]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr2, arr3),
                            "Should return false with [2, 1, 2, 4, 3] and [1, 1, 2]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr3, arr4),
                            "Should return false with [1, 1, 2] and [4, 3, 2, 1, 1]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr5, arr6),
                            "Should return false with [1, 2, 2, 3] and [3, 3, 2, 1]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr7, arr8),
                            "Should return false with [1, 2] and [\"1\", 2]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr9, arr10),
                            "Should return false with [5, '3', 1, 2, 4] and [2, 4, 5, \"3\", 1]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr11, arr12),
                            "Should return false with [1, 2, 3, 4, 5] and [5, '4', 3, \"2\", 1]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr9, arr12),
                            "Should return false with [5, '3', 1, 2, 4] and [5, '4', 3, \"2\", 1]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr2, arr11),
                            "Should return false with [2, 1, 2, 4, 3] and [5, '4', 3, \"2\", 1]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr11, arr13),
                            "Should return false with [1, 2, 3, 4, 5] and ['3', '5', '4', \"1\", 2]");

            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(arr13, arr14),
                            "Should return true with ['3', '5', '4', \"1\", 2] and [\"1\", 2, '3', '4', '5']");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr11, arr14),
                            "Should return false with [1, 2, 3, 4, 5] and [\"1\", 2, '3', '4', '5']");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(arr7, arr15),
                            "Should return false with [1, 2] and []");
        }
Beispiel #2
0
        public void BasicTest1()
        {
            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(new object[] { }, new object[] { }),
                            "Should return true with [] and []");

            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(new object[] { 1, 2 }, new object[] { 2, 1 }),
                            "Should return true with [1, 2] and [2, 1]");

            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(new object[] { "1", "2" }, new object[] { "2", "1" }),
                            "Should return true with [\"1\", \"2\"] and [\"2\", \"1\"]");

            Assert.AreEqual(true, KataArraysSimilar.ArraysSimilar(new object[] { '1', '2' }, new object[] { '2', '1' }),
                            "Should return true with ['1', '2'] and ['2', '1']");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(new object[] { 1, 2 }, new object[] { "1", 2 }),
                            "Should return false with [1, 2] and [\"1\", 2]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(new object[] { 1, 2 }, new object[] { '1', 2 }),
                            "Should return false with [1, 2] and ['1', 2]");

            Assert.AreEqual(false, KataArraysSimilar.ArraysSimilar(new object[] { '1', 2 }, new object[] { "1", 2 }),
                            "Should return false with ['1', 2] and [\"1\", 2]");
        }