コード例 #1
0
ファイル: TestMain.cs プロジェクト: cinemyp/R440O
 public static void Action(ITestModule module)
 {
     if (module.IsExactModule == false)
     {
         MakeSoftMistake();
     }
 }
コード例 #2
0
ファイル: TestModulePanelVM.cs プロジェクト: kaibozhang/1
        void OnAddTestModule()
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog();

            openFileDialog.Filter = "Dll Files (*.dll)|*.dll|Exe Files (*.exe)|*.exe";
            var    result         = openFileDialog.ShowDialog();
            string testModulePath = string.Empty;

            if (result == true)
            {
                testModulePath = openFileDialog.FileName;
            }
            else
            {
                return;
            }

            ITestModule testModule = TestModuleFactory.LoadTestModule(testModulePath);

            if (testModule == null)
            {
                return;
            }
            this.testModuleVMs.Add(new TestModuleVM(testModule));
            RaisePropertyChanged("TestModuleVMs");
        }
コード例 #3
0
        public void GivenThereAreMultipleSameTypedDependencies_WhenDependencyIsRegisteredByHandlerAndDependencyIsRegisteredByHandler_ThenResolutionOfDependenciesCollectionIsCorrect()
        {
            var modules = new ITestModule[] { new TestModule { Name = "1" }, new TestModule { Name = "2" } };

            var container = new ExtendedSimpleIocContainer();
            container.RegisterHandler(typeof(ITestModule), null, (c) => modules[0]);
            container.RegisterHandler(typeof(ITestModule), null, (c) => modules[1]);
            var actualModules = container.GetAllInstances(typeof(ITestModule)).ToArray();

            CollectionAssert.AreEqual(modules, actualModules);
        }
コード例 #4
0
        public static void Run(ITestModule module, string singleTest = null)
        {
            if (singleTest == null)
            {
                foreach (var test in module)
                    Run(test, module);

                return;
            }

            var selectedTest = module.FirstOrDefault(t => t.TestName == singleTest);
            if (selectedTest == null)
                throw new InvalidOperationException("Test not found");    //TODE

            Run(selectedTest, module);
        }
コード例 #5
0
        public static ITestModule LoadTestModule(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(null);
            }
            ITestModule testModule = null;

            try
            {
                testModule = DotNetTestModule.LoadTestModule(filePath);
                return(testModule);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #6
0
 public TestModuleVM(ITestModule testModule) : base(null, true)
 {
     this.testModule = testModule;
 }
コード例 #7
0
 public void Add(ITestModule testFramework)
 {
     _modules.Add(testFramework);
 }
コード例 #8
0
        static void Run(TestBuilder test, ITestModule module)
        {
            string last;
            var testTree = new List<TestBuilder>(new[] { test });
            while ((last = testTree.First()._BasedOn) != null)
            {
                var current = module.FirstOrDefault(t => t.TestName == last);
                if (current == null)
                    throw new InvalidOperationException("There is no test named \"" + last + "\" in this group.");

                if (testTree.Contains(current))
                    throw new InvalidOperationException();

                testTree.Insert(0, current);
            }

            var arranger = new TestArranger(test.Settings);
            foreach (var arr in Filter(testTree, a => !a._UseParentArrange).SelectMany(a => a._Arrange))
            {
                arr(arranger);
                arranger.SetAllSettingsToDefault();
            }

            object result = null;
            Exception exception = null;
            Action work = () =>
            {
                foreach (var act in Filter(testTree, a => !a._UseBaseAct).SelectMany(a => a._Act))
                    result = act(arranger);
            };

            var throws = Filter(testTree, a => !a._UseBaseThrows).SelectMany(a => a._Throws);

            if (throws.Any())
            {
                try
                {
                    work();
                }
                catch (Exception e)
                {
                    exception = e;
                }
            }
            else
            {
                work();
            }

            if (arranger.ShouldHaveBeenCalled.Any())
                throw new InvalidOperationException("methods not called\n" + string.Join("\n", arranger.ShouldHaveBeenCalled));  //TODE

            foreach (var ass in Filter(testTree, a => !a._UseBaseAssert).SelectMany(a => a._Assert))
                ass(arranger, result);

            foreach (var thr in throws)
            {
                if (exception == null)
                    throw new InvalidOperationException();  //TODE

                if (!thr.Key.IsAssignableFrom(exception.GetType()))
                    throw new InvalidOperationException();//TODE

                thr.Value(arranger, exception);
            }
        }
コード例 #9
0
 public AggregateModule(ITestModule test, SingletonModule s)
 {
     _test      = test;
     _singleton = s;
 }
        private void RegisterInstanceDependency(Action <ContainerScenarioDataStoreBase, ITestModule> valueSetter, ITestModule instance)
        {
            var container = _scenarioDataStoreBase.Container;
            var module    = new TestModule {
                Name = "1"
            };

            container.RegisterHandler(typeof(ITestModule), null, (c, r) => instance);
            valueSetter(_scenarioDataStoreBase, instance);
        }