コード例 #1
0
 public void TestExcludedProperties()
 {
     var tester = new AssemblyTester(typeof(IncorrectConstructors).Assembly);
     tester.Exclusions.AddType(typeof(GenericClass<>));
     tester.AddPropertyExclusions(typeof(IncorrectProperties), "Dummy4", "Dummy3");
     tester.TestAssembly(true, false);
 }
コード例 #2
0
 public void TestExcludedPropertiesLambda()
 {
     var tester = new AssemblyTester(typeof(IncorrectConstructors).Assembly);
     tester.Exclusions.AddType(typeof(GenericClass<>));
     tester.AddConstructorExclusion(() => new IncorrectConstructors(string.Empty,0, false,string.Empty));
     tester.AddConstructorExclusion(() => new IncorrectConstructors(string.Empty, string.Empty));
     tester.TestAssembly(false, true);
 }
コード例 #3
0
 public void TestExcludedProperties()
 {
     var tester = new AssemblyTester(typeof(IncorrectConstructors).Assembly);
     tester.Exclusions.AddType(typeof(GenericClass<>));
     tester.AddConstructorExclusion(typeof(IncorrectConstructors), typeof(string), typeof(int), typeof(bool), typeof(string));
     tester.AddConstructorExclusion(typeof(IncorrectConstructors), typeof(string), typeof(string));
     tester.TestAssembly(false, true);
 }
コード例 #4
0
        public void TestExcludedPropertiesWithLambda()
        {
            var tester = new AssemblyTester(typeof(IncorrectConstructors).Assembly);
            tester.Exclusions.AddType(typeof(GenericClass<>));

            tester.AddPropertyExclusion<IncorrectProperties>(x => x.Dummy4);
            tester.AddPropertyExclusion<IncorrectProperties>(x => x.Dummy3);
            tester.TestAssembly(true, false);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Keopz83/AutoTester
        static void Main(string[] args)
        {
            var testSuite = new TestSuite();

            testSuite.Add(
                methodName: nameof(SampleAssembly.ClassWithMethodsDefaultTypes.SumTwoInts),
                testCases: new TestCase()
            {
                Inputs = new object[] { 2, 3 },
                Output = 5
            }
                );

            testSuite.Add(
                methodName: nameof(SampleAssembly.ClassWithMethodsDefaultTypes.MultiplyTwoInts),
                testCases: new TestCase()
            {
                Inputs = new object[] { 2, 3 },
                Output = 6
            }
                );

            testSuite.Add(
                methodName: nameof(SampleAssembly.ClassWithMethodsDefaultTypes.StringLengthMatch),
                testCases: new TestCase()
            {
                Inputs = new object[] { "abc", 3 },
                Output = true
            }
                );


            var customType = new ClassWithDefaultCtr()
            {
                StrProp = "abc"
            };

            testSuite.Add(
                methodName: nameof(SampleAssembly.ClassWithMethodCustomType.MethodWithCustomType),
                testCases: new TestCase()
            {
                Inputs = new object[] { customType, 3 },
                Output = true
            }
                );

            var projectFilePath = @"C:\Users\user1\source\repos\AutoTester\SampleAssembly\SampleAssembly.csproj";

            var results = AssemblyTester.Run(projectFilePath, testSuite);

            Console.WriteLine($"Test run global result: '{results}'");

            Console.ReadLine();
        }
コード例 #6
0
        public void ExcludeProperty_prevents_testing_a_property()
        {
            var sut = new AssemblyTester(Assembly.Load("NSimpleTester.Tests.PropertyErrors"));

            // verity the assembly has issues first so we know the test is valid.
            Assert.Throws <InvalidOperationException>(() => sut.TestAssembly());

            sut.ExcludeProperty("TestTypeWBadINotifyPropertyChanged", "PropertyTwo");

            sut.TestAssembly();
        }
コード例 #7
0
        public void ExcludeEqualityTests_prevents_any_equality_tests()
        {
            var sut = new AssemblyTester(Assembly.Load("NSimpleTester.Tests.EqualityErrors"));

            // verity the assembly has issues first so we know the test is valid.
            Assert.Throws <InvalidOperationException>(() => sut.TestAssembly());

            sut.ExcludeEqualityTests();

            sut.TestAssembly();
        }
コード例 #8
0
        public void ExcludeConstructor_prevents_any_constructor_tests()
        {
            var sut = new AssemblyTester(Assembly.Load("NSimpleTester.Tests.ConstructorErrors"));

            // verity the assembly has issues first so we know the test is valid.
            Assert.Throws <InvalidOperationException>(() => sut.TestAssembly());

            sut.ExcludeConstructor("ConstructorParameterNotMapped", new MethodSignature(new Type[] {}));

            sut.TestAssembly();
        }
コード例 #9
0
        public void ExcludeClass_prevents_executing_any_tests_on_a_class()
        {
            var sut = new AssemblyTester(Assembly.Load("NSimpleTester.Tests.ConstructorErrors"));

            // verity the assembly has issues first so we know the test is valid.
            Assert.Throws <InvalidOperationException>(() => sut.TestAssembly());

            sut.ExcludeClass("ConstructorParameterNotMapped");

            sut.TestAssembly();
        }
コード例 #10
0
        public void TestAll_suceeds()
        {
            var testResults = AssemblyTester.TestAll("SampleAssembly");

            Assert.IsTrue(testResults.Succeeded, "Expects test to succeed.");
        }