public void RunTestCommand_Will_Execute_Passing_Test()
        {
            TestMethodViewModel viewModel = new TestMethodViewModel(AddResultControl, ClearResultControl);

            MockTestManager testManager = new MockTestManager();
            testManager.PassTests = true;

            viewModel.TestManager = testManager;

            TestFixture fixture = new TestFixture();

            TestMethod testMethod = new TestMethod();
            testMethod.Name = "test1";
            fixture.Tests = new List<TestMethod>();
            fixture.Tests.Add(testMethod);

            viewModel.Tests = new List<TestFixture>();
            viewModel.Tests.Add(fixture);

            viewModel.RunTestsCommand.Execute(null);

            Thread.Sleep(5000);

            Confirm.Equal(1, viewModel.TestsPassed);
            Confirm.Equal(0,viewModel.TestsFailed);
        }
Ejemplo n.º 2
0
        public IList<TestFixture> GetTests(string testType,string testCategory)
        {
            List<Type> allTypes = new List<Type>();

            Assembly currentAssembly = Assembly.GetEntryAssembly();
            Type[] types = currentAssembly.GetTypes();

            var q1 = from t in types
                     where Attribute.IsDefined(t, typeof(TestClass)) == true orderby t.Name
                     select t;

            allTypes.AddRange(q1.ToArray());

            string[] dlls = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll");

            foreach (string name in dlls)
            {
                currentAssembly = Assembly.LoadFile(name);
                types = currentAssembly.GetTypes();

                var q2 = from t in types
                         where Attribute.IsDefined(t, typeof(TestClass)) == true
                         select t;

                allTypes.AddRange(q2.ToArray());
            }

            var sortedTypes = from t in allTypes orderby t.Name ascending select t;

            IList<TestFixture> allTests = new List<TestFixture>();
            foreach (Type t in sortedTypes.ToList<Type>())
            {
                TestFixture test = new TestFixture();
                test.Name = t.Name;
                test.Tests = methodManager.GetTestsInTestClass(t, testType,testCategory);

                if (test.Tests.Count > 0)
                {
                    allTests.Add(test);
                }
            }
            return allTests;
        }