コード例 #1
0
        public void ResolveSetup()
        {
            // Arrange...
            var configLibrary = new List <Config>()
            {
                Config.New("D[1]")
                .AddProperty("a", "1")
            };

            var testConfig = Config.New("TestConfig")
                             .AddProperty("IMPORT.DefaultSetup", "D[1]")
                             .AddProperty("b", "1");

            var expectedCases = new[] {
                "p:a(1) p:b(1)"
            };

            // Act...
            var testCases = TestCaseLoader.CasesFromConfigs(testConfig, configLibrary);

            // Assert
            var testCaseString = testCases.Select(tc => TestCaseLoader.CaseToString(tc)).ToList();

            CollectionAssert.AreEquivalent(expectedCases, testCaseString);
        }
コード例 #2
0
        public void ResolveSetup_3DefaultSetups2LevelsDeepWithExpansionsReversePriority()
        {
            // Arrange...
            var configLibrary = new List <Config>()
            {
                Config.New("D[1]")
                .AddProperty("a", "1"),
                Config.New("D[2]")
                .AddProperty("a", new[] { "2.1", "2.2" }),
                Config.New("D[3]")
                .AddProperty("IMPORT.DefaultSetup", "D[2]")
            };

            var testConfig = Config.New("TestConfig")
                             .AddProperty("IMPORT.DefaultSetup", "D[3]")
                             .AddProperty("IMPORT.DefaultSetup2", new[] { "D[1]" });

            var expectedCases = new[] {
                "p:a(1)",
            };

            // Act...
            var testCases = TestCaseLoader.CasesFromConfigs(testConfig, configLibrary);

            // Assert
            var testCaseString = testCases.Select(tc => TestCaseLoader.CaseToString(tc)).ToList();

            CollectionAssert.AreEquivalent(expectedCases, testCaseString);
        }
コード例 #3
0
        public void ExpandSetup_GivenPermutationSet_Expect4Permutations()
        {
            // Arrange...
            var configLibrary = new List <Config>();
            var config        = Config.New("TestConfig")
                                .AddProperty("a", new [] { "1", "2" })
                                .AddProperty("b", new [] { "1", "2" })
                                .AddProperty("c", "1");

            var expectedCases = new[] {
                "p:a(1) p:b(1) p:c(1)",
                "p:a(1) p:b(2) p:c(1)",
                "p:a(2) p:b(1) p:c(1)",
                "p:a(2) p:b(2) p:c(1)"
            };

            // Act...
            var testCases = TestCaseLoader.CasesFromConfigs(config, configLibrary);

            // Assert
            var testCaseString = testCases.Select(tc => TestCaseLoader.CaseToString(tc)).ToList();

            Assert.AreEqual(4, testCases.Count());
            CollectionAssert.AreEquivalent(expectedCases, testCaseString);
        }
コード例 #4
0
        public void ResolveSetup_2DefaultSetupsWithExpandedProperties()
        {
            // Arrange...
            var configLibrary = new List <Config>()
            {
                Config.New("D[1]")
                .AddProperty("a", new[] { "1", "2", "3" })
                .AddProperty("b", "1"),
                Config.New("D[2]")
                .AddProperty("a", new[] { "4", "5" })
                .AddProperty("c", "1")
            };

            var testConfig = Config.New("TestConfig")
                             .AddProperty("IMPORT.DefaultSetup", new[] { "D[1]" })
                             .AddProperty("IMPORT.DefaultSetup2", new[] { "D[2]" })
                             .AddProperty("d", "1");

            var expectedCases = new[] {
                "p:a(4) p:b(1) p:c(1) p:d(1)",
                "p:a(5) p:b(1) p:c(1) p:d(1)"
            };

            // Act...
            var testCases = TestCaseLoader.CasesFromConfigs(testConfig, configLibrary);

            // Assert
            var testCaseString = testCases.Select(tc => TestCaseLoader.CaseToString(tc)).ToList();

            CollectionAssert.AreEquivalent(expectedCases, testCaseString);
        }
コード例 #5
0
        public void Test04()
        {
            string TestInputPath       = @"Mathematics\Algebra\TriangleNumbers\input04.txt";
            string ExpectedResultsPath = @"Mathematics\Algebra\TriangleNumbers\output04.txt";

            Assert.IsTrue(TestCaseLoader.FileTest(TestInputPath, ExpectedResultsPath, Solution.Main));
        }
コード例 #6
0
        public void Test05()
        {
            string TestInputPath       = @"Algorithms\GraphTheory\bfsshortreach\input05.txt";
            string ExpectedResultsPath = @"Algorithms\GraphTheory\bfsshortreach\output05.txt";

            Assert.IsTrue(TestCaseLoader.FileTest(TestInputPath, ExpectedResultsPath, Solution.Main));
        }
コード例 #7
0
        public void Test05()
        {
            string input =
                @"10
5351871996120528
2248813659738258
2494359640703601
6044763399160734
3271269997212342
4276346434761561
2372239019637533
5624204919070546
9493965694520825
8629828692375133";
            string expectedOutput =
                @"578351320
404664464
20752136
999516029
743537718
323730244
174995256
593331567
136582381
305527433";
            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #8
0
        public void Test02()
        {
            string TestInputPath       = @"Algorithms\Sorting\Quicksort2Sorting\input02.txt";
            string ExpectedResultsPath = @"Algorithms\Sorting\Quicksort2Sorting\output02.txt";

            Assert.IsTrue(TestCaseLoader.FileTest(TestInputPath, ExpectedResultsPath, Solution.Main));
        }
コード例 #9
0
        public void ResolveSetup_1ExpandedDefaultSetupsEachWith2ExpandedProperties()
        {
            // Arrange...
            var configLibrary = new List <Config>()
            {
                Config.New("D[1]")
                .AddProperty("a", new[] { "T", "F" }),
                Config.New("D[2]")
                .AddProperty("b", new[] { "T", "F" })
            };

            var testConfig = Config.New("TestConfig")
                             .AddProperty("IMPORT.DefaultSetup", new[] { "D[1]", "D[2]" })
                             .AddProperty("c", new[] { "T", "F" });

            var expectedCases = new[] {
                "p:a(T) p:c(T)",
                "p:a(T) p:c(F)",
                "p:a(F) p:c(T)",
                "p:a(F) p:c(F)",
                "p:b(T) p:c(T)",
                "p:b(T) p:c(F)",
                "p:b(F) p:c(T)",
                "p:b(F) p:c(F)"
            };

            // Act...
            var testCases = TestCaseLoader.CasesFromConfigs(testConfig, configLibrary);

            // Assert
            var testCaseString = testCases.Select(tc => TestCaseLoader.CaseToString(tc)).ToList();

            CollectionAssert.AreEquivalent(expectedCases, testCaseString);
        }
コード例 #10
0
        public void GetCaseSet_GivenMockSetup1()
        {
            var mockNodeTree      = GetMockNodeTreeUsingFluentTreeBuilder();
            var expectedTestCases = ResultTestCasesForAllMocks().Select(tc => CaseToString(tc)).OrderBy(s => s).ToList();
            var actualTestCases   = TestCaseLoader.CasesFromNodeTree(mockNodeTree).Select(tc => CaseToString(tc)).OrderBy(s => s).ToList();

            //File.WriteAllText(Directory.GetCurrentDirectory() + "\\ExpectedCases.xls", expectedTestCases.Aggregate((a,b) => $"{a}\n{b}"));
            //File.WriteAllText(Directory.GetCurrentDirectory() + "\\ActualCases.xls", actualTestCases.Aggregate((a,b) => $"{a}\n{b}"));
            CollectionAssert.AreEquivalent(expectedTestCases, actualTestCases);
        }
コード例 #11
0
        public void MyTest02()
        {
            string input =
                @"1
3001";

            string expectedOutput = Math.Pow(3001, 2).ToString();
            bool   result         = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #12
0
        public void MyTest01()
        {
            string input =
                @"1
21";
            string expectedOutput =
                @"Go On Bob 6";

            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #13
0
        public void MyTest02()
        {
            string input =
                @"1
27";
            string expectedOutput =
                @"Better Luck Next Time";

            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #14
0
        public void GetCaseSet_GivenConfigs()
        {
            var configLibrary     = GetMockConfigsLibrary();
            var mainConfig        = configLibrary.Single(c => c.Name == "TestConfig");
            var compiledNodeTree  = TestCaseLoader.NodeTreeFromConfigs(mainConfig, configLibrary);
            var expectedTestCases = ResultTestCasesForAllMocks().Select(tc => CaseToString(tc)).OrderBy(s => s).ToList();
            var actualTestCases   = TestCaseLoader.CasesFromNodeTree(compiledNodeTree).Select(tc => CaseToString(tc)).OrderBy(s => s).ToList();

            //File.WriteAllText(Directory.GetCurrentDirectory() + "\\ExpectedCases.xls", expectedTestCases.Aggregate((a,b) => $"{a}\n{b}"));
            //File.WriteAllText(Directory.GetCurrentDirectory() + "\\ActualCases.xls", actualTestCases.Aggregate((a,b) => $"{a}\n{b}"));
            CollectionAssert.AreEquivalent(expectedTestCases, actualTestCases);
        }
コード例 #15
0
        public void Test00()
        {
            string input =
                @"2
3
4";
            string expectedOutput =
                @"2
3";

            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #16
0
        public void Test01()
        {
            string input =
                @"9
9 8 6 7 3 5 4 1 2";
            string expectedOutput =
                @"1 2
4 5
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9";
            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #17
0
        public void MyTest01()
        {
            string input =
                @"1
200";
            int expectedSum = 0;

            for (int i = 1; i != 201; i++)
            {
                expectedSum += 2 * i - 1;
            }
            string expectedOutput = expectedSum.ToString();
            bool   result         = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #18
0
ファイル: EasySumTest.cs プロジェクト: smorken/hackerrank
        public void MyTest02()
        {
            string input =
                @"4
10 11
11 10
17 19
19 17";
            string expectedOutput = String.Format(
                @"{0}
{1}
{2}
{3}", EasySum(10, 11), EasySum(11, 10), EasySum(17, 19), EasySum(19, 17));
            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #19
0
        public void Test01()
        {
            string input =
                @"4
1
3
5
11";
            string expectedOutput =
                @"-1
555
33333
55555533333";
            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #20
0
        public void Test03()
        {
            string input =
                @"1
10 6
3 1
10 1
10 1
3 1
1 8
5 2
3";
            string expectedOutput = @"6 -1 -1 -1 -1 -1 12 -1 12";
            bool   result         = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #21
0
        public void Test03()
        {
            string input =
                @"20
45 25 46 48 28 6 13 5 36 44 7 4 11 30 24 34 15 31 38 49";

            string inputLine2 = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)[1];

            using (TempFile inputFile = new TempFile("input.txt", input))
                using (TempFile outputFile = new TempFile("output.txt", ""))
                {
                    TestCaseLoader.SetUp("input.txt", "output.txt");
                    Solution.Main(null);
                    TestCaseLoader.TearDown();
                    CheckResult(inputLine2, TestCaseLoader.GetOutput()[0]);
                }
        }
コード例 #22
0
        public void Test04()
        {
            string input =
                @"50
-13 68 -43 -71 -39 -10 40 -49 -19 -3 -70 -62 -76 -94 -73 64 72 -5 88 2 -63 92 -40 16 49 47 -86 -51 -9 -14 96 74 -22 -34 38 -12 6 63 19 -69 14 -90 -27 76 54 57 -87 -91 43 -92";

            string inputLine2 = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)[1];

            using (TempFile inputFile = new TempFile("input.txt", input))
                using (TempFile outputFile = new TempFile("output.txt", ""))
                {
                    TestCaseLoader.SetUp("input.txt", "output.txt");
                    Solution.Main(null);
                    TestCaseLoader.TearDown();
                    CheckResult(inputLine2, TestCaseLoader.GetOutput()[0]);
                }
        }
コード例 #23
0
        public void Test01()
        {
            string input =
                @"2
4 2
1 2
1 3
1
3 1
2 3
2";
            string expectedOutput =
                @"6 6 -1
-1 6";
            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #24
0
        public void Test01()
        {
            string input =
                @"9
9 8 6 7 3 5 4 1 2";

            string expectedOutput =
                @"8 9 6 7 3 5 4 1 2
6 8 9 7 3 5 4 1 2
6 7 8 9 3 5 4 1 2
3 6 7 8 9 5 4 1 2
3 5 6 7 8 9 4 1 2
3 4 5 6 7 8 9 1 2
1 3 4 5 6 7 8 9 2
1 2 3 4 5 6 7 8 9";

            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #25
0
        public void ExpandSetup_GivenPermutationSet_Expect1Permutation()
        {
            // Arrange...
            var configLibrary = new List <Config>();
            var config        = Config.New("TestConfig")
                                .AddProperty("a", "1")
                                .AddProperty("b", "1")
                                .AddProperty("c", "1");
            var expectedCases = new[] {
                "p:a(1) p:b(1) p:c(1)"
            };

            // Act...
            var nodeTree  = TestCaseLoader.NodeTreeFromConfigs(config, configLibrary);
            var testCases = TestCaseLoader.CasesFromNodeTree(nodeTree);

            // Assert...
            var testCaseString = testCases.Select(tc => TestCaseLoader.CaseToString(tc)).ToList();

            Assert.AreEqual(expectedCases, testCaseString);
        }
コード例 #26
0
        public void Test02()
        {
            string input =
                @"10
2 3 4 5 6 7 8 9 10 1";

            string expectedOutput =
                @"2 3 4 5 6 7 8 9 10 10
2 3 4 5 6 7 8 9 9 10
2 3 4 5 6 7 8 8 9 10
2 3 4 5 6 7 7 8 9 10
2 3 4 5 6 6 7 8 9 10
2 3 4 5 5 6 7 8 9 10
2 3 4 4 5 6 7 8 9 10
2 3 3 4 5 6 7 8 9 10
2 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10";

            bool result = TestCaseLoader.TempFileTest(input, expectedOutput, Solution.Main);

            Assert.IsTrue(result);
        }
コード例 #27
0
ファイル: InlinerTests.cs プロジェクト: wildbit/style-merge
 public InlinerTests()
 {
     _loader = new TestCaseLoader();
 }