Beispiel #1
0
        public void FactorialTest()
        {
            TestCase1[] factorial_data = new TestCase1[Math2.FactorialTable.Length];

            // step 1: compute factorials using big integer to avoid trunctaion errors


            factorial_data[0] = new TestCase1(0, 1);
            for (int i = 1; i < Math2.FactorialTable.Length; i++)
            {
                factorial_data[i] = new TestCase1(i, BigInt.Factorial(i));
            }

            // Run the test case

            TestCaseSet <int>[] testCases =
            {
                new TestCaseSet <int>(factorial_data, "Factorial: Complete table", 1),
            };

            NumericFunctionTest.RunSet(Math2.Factorial, "Factorial", testCases);

            Assert.AreEqual(double.PositiveInfinity, Math2.Factorial(Math2.FactorialTable.Length));
            Assert.AreEqual(double.PositiveInfinity, Math2.Factorial(int.MaxValue));

            // TODO: negative
        }
Beispiel #2
0
        public void ShouldInjectLazilyForDefaultInstanceRegistrations()
        {
            var sample = new TestCase1();

            locator
            .Register(Given <ITestInterface> .Then(sample))
            .Register(Given <TestClass> .Then <TestClass>());

            var instance = locator.GetInstance <TestClass>();

            Assert.AreSame(sample, instance.Invoke());
        }
Beispiel #3
0
        public ActionResult HandelForm(Test ApplicatioNames, Test TestTypes, Test ProjectNames)
        {
            string    ProjectName    = ProjectNames.ProjectName.ToString();
            string    TestType       = TestTypes.TestType.ToString();
            string    ApplicatioName = ApplicatioNames.ApplicatioName.ToString();
            TestCase1 Testobj        = new TestCase1();

            switch (ProjectName)
            {
            case "lifeAlborzInsurance":
            {
                switch (ApplicatioName)
                {
                case "AlborzContactManagingDirector":
                {
                    switch (TestType)
                    {
                    case "AcceptanceTest":
                        string[] testrepo = Testobj.TestAction1();
                        IList <TestingResult> testindexlist = new List <TestingResult>();
                        testindexlist.Add(new TestingResult()
                                {
                                    TestCheck1 = ApplicatioName, TestCheck2 = ProjectName, TestCheck3 = TestType
                                });

                        TestingResult aaa = new TestingResult();
                        aaa.TestCheck1 = ApplicatioName;
                        aaa.TestCheck2 = ProjectName;
                        aaa.TestCheck3 = TestType;

                        _context.Add(aaa);
                        _context.SaveChangesAsync();
                        ViewData["testindexlist"] = testindexlist;
                        return(View("TestResult"));
                    }
                }
                break;
                }
                break;
            }
            }

            return(View("Index"));
        }
Beispiel #4
0
        public void ShouldInjectLazilyForConditionalInstanceRegistrations()
        {
            var sample1 = new TestCase1();
            var sample2 = new TestCase2();

            locator
            .Register(Given <ITestInterface> .When <int>(i => i == 1).Then(sample1))
            .Register(Given <ITestInterface> .When <int>(i => i == 2).Then(sample2))
            .Register(Given <TestClass> .Then <TestClass>());

            locator.AddContext(1);
            var instance = locator.GetInstance <TestClass>();

            Assert.AreSame(sample1, instance.Invoke());

            locator.Store.Get <IContextStore>().Clear();
            locator.AddContext(2);

            instance = locator.GetInstance <TestClass>();
            Assert.AreSame(sample2, instance.Invoke());
        }
Beispiel #5
0
        public void FactorialTableTest()
        {
            TestCase1[] factorial_data = new TestCase1[Math2.FactorialTable.Length];

            // step 1: compute factorials using big integer to avoid trunctaion errors


            factorial_data[0] = new TestCase1(0, 1);
            for (int i = 1; i < Math2.FactorialTable.Length; i++)
            {
                factorial_data[i] = new TestCase1(i, BigInt.Factorial(i));
            }

            // Run the test case

            TestCaseSet <int>[] testCases =
            {
                new TestCaseSet <int>(factorial_data, "Factorial: Complete table", 1),
            };

            NumericFunctionTest.RunSet((int i) => Math2.FactorialTable[i], "Factorial Table", testCases);
        }
Beispiel #6
0
        public void Factorial2Test()
        {
            TestCase1[] factorial2_data = new TestCase1[250];

            // step 1: compute factorials using big integer to avoid trunctaion errors


            factorial2_data[0] = new TestCase1(-1, 1);
            factorial2_data[1] = new TestCase1(0, 1);
            for (int i = 2; i < factorial2_data.Length; i++)
            {
                factorial2_data[i] = new TestCase1(i - 1, BigInt.Factorial2(i - 1));
            }

            // Run the test case

            TestCaseSet <int>[] testCases =
            {
                new TestCaseSet <int>(factorial2_data, "Factorial: Complete table", 10),
            };

            NumericFunctionTest.RunSet(Math2.Factorial2, "Factorial2", testCases);
        }
Beispiel #7
0
 public TestContainer(TestCase1 testCase)
 {
     this.testCase = testCase;
 }
Beispiel #8
0
        public void TestMethod1()
        {
            TestCase1[] testSet = new TestCase1[]
            {
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 1, 100 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 1, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null), result = true
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null), result = true
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 1, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 1, 100 }
                    }, null), result = true
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 150 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 200 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 150 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null), result = true
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 200 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 0, 100 }
                    }, null), result = true
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 150 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 200 }
                    }, null), result = false
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 150 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null), result = true
                },
                new TestCase1 {
                    army1 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 200 }
                    }, null),
                    army2 = new Fleet(0, new Dictionary <int, int> {
                        { 2, 100 }
                    }, null), result = true
                }
            };

            foreach (TestCase1 testCase in testSet)
            {
                Assert.IsTrue(BattleLogic.ArrangeBattle(testCase.army1, testCase.army2) == testCase.result);
                Assert.IsTrue(testCase.result ? testCase.army2.IsEmpty : testCase.army1.IsEmpty);
            }
        }