public RuleConfigurable(RuleTestDelegate testDelegate, RuleExecuteDelegate execDelegate, TestModule testModule, ExecModule execModule){ TestDelegate = testDelegate; ExecDelegate = execDelegate; TestModule = testModule; ExecModule = execModule; }
public void SetUp() { _module = new TestModule(); _mockFileSystemWorker = new Mock<IFileSystemWorker>(); _module.RegisterType<IDpLocalStorage, DpLocalStorage>(); _module.RegisterInstance(_mockFileSystemWorker.Object); }
public void GetTokenFromRequestWithoutAuthorizationHeaderReturnsNull() { var sut = new TestModule(); var request = new HttpRequest(string.Empty, "http://www.example.com", string.Empty); var extractedToken = sut.GetTokenFromRequestTest(request); Assert.Null(extractedToken); }
public RuleConfigurable(RuleTestDelegate testDelegate, RuleExecuteDelegate execDelegate, TestModule testModule, ExecModule execModule, RuleInitContextDelefate initDelegate, InitContextModule initModule){ TestDelegate = testDelegate; ExecDelegate = execDelegate; TestModule = testModule; ExecModule = execModule; InitDelegate = initDelegate; InitModule = initModule; }
public Given_a_module_that_requires_security_claims() { _testModule = new TestModule(); _testModule.RequiresSecurityClaims(claims => claims.Any( claim => claim.Type == ClaimTypes.Country && claim.Value.Equals("IE", StringComparison.Ordinal))); _context = new NancyContext(); _environment = new Dictionary<string, object>(); _context.Items.Add(NancyOwinHost.RequestEnvironmentKey, _environment); }
public void ForRequest_should_throw_if_mediatr_not_set() { var module = new TestModule(new Mediator(null, null)); module.SetMediatR(null); module.Invoking(y => y.ForRequest<TestMessage>("/path")) .ShouldThrow<InvalidOperationException>(); module.Invoking(y => y.ForRequest<TestMessageWithResponse, string>("/path")) .ShouldThrow<InvalidOperationException>(); }
public void ReactContextNativeModuleBase_ArgumentChecks() { ArgumentNullException ex = Assert.Throws<ArgumentNullException>( () => { new TestModule(null); } ); Assert.AreEqual("reactContext", ex.ParamName); var context = new ReactContext(); var module = new TestModule(context); Assert.AreSame(context, module.Context); }
public void GetTokenFromRequestWithAuthorizationHeaderReturnsToken() { var sut = new TestModule(); var request = new HttpRequest(string.Empty, "http://www.example.com", string.Empty); var expectedToken = "access-token"; request.AddHeader("Authorization", "Bearer " + expectedToken); var extractedToken = sut.GetTokenFromRequestTest(request); Assert.Equal(expectedToken, extractedToken); }
public void SetUp() { _module = new TestModule(); _mockSdk = new Mock<IWdApi>(); _mockWsMessage = new WsMessageMock(); _mockDocRepo = new Mock<IWdDocumentRepository>(); _mockProcessLauncher = new Mock<IProcessLauncher>(); _module.RegisterType<IOpenFileDialog, OpenFileDialog>(); _module.RegisterInstance(_mockSdk.Object); _module.RegisterInstance(_mockWsMessage.Mock.Object); _module.RegisterInstance(_mockDocRepo.Object); _module.RegisterInstance(_mockProcessLauncher.Object); }
public void SetUp() { this.module = new TestModule(); mockSdk = new Mock<IWdApi>(); mockWsMessage = new WsMessageMock(); mockDocRepo = new Mock<IWdDocumentRepository>(); module.RegisterType<ISaveFileDialog, SaveFileDialog>(); module.RegisterInstance<IWdApi>(mockSdk.Object); module.RegisterInstance<IWsMessage>(mockWsMessage.Mock.Object); module.RegisterInstance<IWdDocumentRepository>(mockDocRepo.Object); module.RegisterType<IDPConfigurator, WdConfigurator>(); configurator = (WdConfigurator)module.Resolve<IDPConfigurator>(); }
public void SetUp() { _module = new TestModule(); _mockWsMessage = new WsMessageMock(); _mockOpenDialog = new Mock<IOpenFileDialog>(); _mockSaveDialog = new Mock<ISaveFileDialog>(); _mockDocRepo = MockUtils.CreateRepositoryMock(); _mockProcessLauncher = new Mock<IProcessLauncher>(); _module.RegisterInstance<IWsMessage>(_mockWsMessage.Mock.Object); _module.RegisterInstance<IOpenFileDialog>(_mockOpenDialog.Object); _module.RegisterInstance<ISaveFileDialog>(_mockSaveDialog.Object); _module.RegisterInstance<IWdDocumentRepository>(_mockDocRepo.Object); _module.RegisterInstance<IProcessLauncher>(_mockProcessLauncher.Object); _module.RegisterType<DocumentProviderImpl, DocumentProviderImpl>(); }
TestModule GetTestModule() { var res = new TestModule(); res.RegisterAsReal(); var mockWsMessage = new WsMessageMock(); var mockOpenDialog = new Mock<IOpenFileDialog>(); var mockSaveDialog = new Mock<ISaveFileDialog>(); var mockDocRepo = MockUtils.CreateRepositoryMock(); var mockProcessLauncher = new Mock<IProcessLauncher>(); res.RegisterInstance(MockUtils.GetDefaultSdkMock().Object); res.RegisterInstance<IOptionsStorage>(new Mock<IOptionsStorage>().Object); res.RegisterInstance<IWsMessage>(mockWsMessage.Mock.Object); res.RegisterInstance<IOpenFileDialog>(mockOpenDialog.Object); res.RegisterInstance<ISaveFileDialog>(mockSaveDialog.Object); res.RegisterInstance<IWdDocumentRepository>(mockDocRepo.Object); res.RegisterInstance<IProcessLauncher>(mockProcessLauncher.Object); return res; }
public void disassemble_type_datetime() => TestModule.SafeImport(typeof(DateTime)).Resolve() .Disassemble();
public Given_a_module_that_requires_owin_authentication() { _testModule = new TestModule(); _testModule.RequiresMSOwinAuthentication(); }
public void disassemble_type_marshal() => TestModule.SafeImport(typeof(Marshal)).Resolve() .Disassemble();
public void disassemble_type_assembly() => TestModule.SafeImport(typeof(Assembly)).Resolve() .Disassemble();
public void Add(TestModule testModule) { testModule.IsEnabled = true; _context.TestModules.Add(testModule); }
public void disassemble_type_char() => TestModule.SafeImport(typeof(char)).Resolve() .Disassemble();
public bool TestSaved(TestToSave test) { return(TestModule.TestSaved(test)); }
public void disassemble_type_task() => TestModule.SafeImport(typeof(Task)).Resolve() .Disassemble();
public void disassemble_type_fieldinfo() => TestModule.SafeImport(typeof(FieldInfo)).Resolve() .Disassemble();
public void disassemble_type_path() => TestModule.SafeImport(typeof(Path)).Resolve() .Disassemble();
public void disassemble_type_filestream() => TestModule.SafeImport(typeof(FileStream)).Resolve() .Disassemble();
public void disassemble_type_iconvertible() => TestModule.SafeImport(typeof(IConvertible)).Resolve() .Disassemble();
public void disassemble_type_gc() => TestModule.SafeImport(typeof(GC)).Resolve() .Disassemble();
public bool GetIsSquare(TestModule.Shape shape) { return shape.IsSquare; }
public void OnAuthenticateRequestWithInvalidTokenCallsOnValidateTokenException() { var application = new TestApplication(new TokenValidationParameters() { AllowedAudiences = this.allowedAudiences, SigningToken = new X509SecurityToken(this.certificate), ValidIssuer = "self" }); var request = new HttpRequest(string.Empty, "http://www.example.com", string.Empty); request.AddHeader("Authorization", "Bearer invalid-token"); var sut = new TestModule(); sut.Init(application); var principal = (ClaimsPrincipal)sut.GetPrincipalFromRequestTest(request); Assert.NotNull(sut.ValidationTokenException); Assert.False(principal.Identity.IsAuthenticated); Assert.Empty(principal.Claims); }
public bool studentForTest(StudentForTestVM[] students) { return(TestModule.studentForTest(students)); }
public void import_system_methodinfo() => TestModule .SafeImport(typeof(Console).GetMethods().First()) .Should().Not.Be.Null();
public List <MarkVM> GetGradeChart(int id) { return(TestModule.GetGradeChart(id)); }
public void Update(TestModule testModule) { _context.TestModules.Update(testModule); }
public string getLink(int id) { return(TestModule.getLink(id)); }
public void Remove(TestModule testModule) { testModule.IsEnabled = false; testModule.DisabledAt = DateTime.UtcNow; _context.TestModules.Update(testModule); }
public TestVM GetTestById(int testId) { return(TestModule.GetByTestId(testId)); }
public void disassemble_type_attribute() => TestModule.SafeImport(typeof(Attribute)).Resolve() .Disassemble();
public TestForStudentVM GetByTestIdForStudent(StudentAndTestId model) { return(TestModule.GetByTestIdForStudent(model.testId, model.studentId)); }
public void Setup() { module = new TestModule(); var container = Container.Create(module); testObj = container.Get<NeedsProvider>(); }
public QuestionVM GetByQuestionForManager(int questionId) { return(TestModule.GetByQuestionForManager(questionId)); }
public void disassemble_type_console() => TestModule.SafeImport(typeof(Console)).Resolve() .Disassemble();
public void ConfiguresApplicationAndModulesFromTemplate() { StaticApplicationContext appContext = CreateTestContext(); HttpApplicationConfigurer h; RootObjectDefinition rod; h = new HttpApplicationConfigurer(); rod = new RootObjectDefinition(); rod.PropertyValues.Add("TestObject", new RuntimeObjectReference("testObject")); h.ApplicationTemplate = rod; rod = new RootObjectDefinition(); rod.PropertyValues.Add("TestObject", new RuntimeObjectReference("testObject1")); h.ModuleTemplates.Add("TestModule1", rod); rod = new RootObjectDefinition(); rod.PropertyValues.Add("TestObject", new RuntimeObjectReference("testObject2")); h.ModuleTemplates.Add("TestModule2", rod); TestModule m1 = new TestModule(); TestModule m2 = new TestModule(); TestApplication appObject = new TestApplication(new ModuleEntry[] { new ModuleEntry("TestModule1", m1) , new ModuleEntry("TestModule2", m2), }); HttpApplicationConfigurer.Configure(appContext, appObject); // app configured Assert.AreEqual(appContext.GetObject("testObject"), appObject.TestObject); // modules configured Assert.AreEqual(appContext.GetObject("testObject1"), m1.TestObject); Assert.AreEqual(appContext.GetObject("testObject2"), m2.TestObject); }
public double ComputeArea(TestModule.Shape shape) { return TestModule.Area(shape); }
public LtmTestModuleItem(TestModule item) : base(item) { }
public double GetSquareSize(TestModule.Shape shape) { return ((TestModule.Shape.Square) shape).Item; }
public void import_system_fieldinfo() => TestModule .SafeImport(typeof(Tuple <string, string>).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).First()) .Should().Not.Be.Null();
public void OnAuthenticateRequestWithTokenSetsApplicationContextUser() { var application = new TestApplication(new TokenValidationParameters() { AllowedAudiences = this.allowedAudiences, SigningToken = new X509SecurityToken(this.certificate), ValidIssuer = "self" }); var request = new HttpRequest(string.Empty, "http://www.example.com", string.Empty); request.AddHeader("Authorization", "Bearer " + this.GenerateAuthToken("http://www.example.com")); var sut = new TestModule(); sut.Init(application); var principal = (ClaimsPrincipal)sut.GetPrincipalFromRequestTest(request); Assert.True(principal.Identity.IsAuthenticated); Assert.True(principal.HasClaim(ClaimTypes.Name, "Username")); Assert.True(principal.HasClaim(ClaimTypes.Role, "User")); }
public void GetTypes() { List<Type> types = TestModule.GetTypes().ToList(); Assert.Equal(1, types.Count); Assert.Equal("System.Reflection.TestModule.Dummy, System.Reflection.TestModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", types[0].AssemblyQualifiedName); }
public void import_system_constructorinfo() => TestModule .SafeImport(typeof(Tuple <string, string>).GetConstructors().First()) .Should().Not.Be.Null();
private void ScanDocument() { try { // Omicron Test Module index is between 1 and TestModules.Count int startPosition = 1; // Local thread variable to hold total module number after deletion. int moduleCounter = 0; // Update total module number. // MyCommons.TotalModuleNumber = this.OmicronDocument.TestModules.Count; MyCommons.TotalModuleNumber = OmicronDocument.OLEObjects.Count; MyCommons.MyViewModel.ModuleProgressBarMax = MyCommons.TotalModuleNumber; MyCommons.MyViewModel.UpdateCommand.Execute(null); Debug.WriteLine("SCANNING thread: {0}", Thread.CurrentThread.GetHashCode()); Debug.WriteLine("Total TestModule: {0} ", MyCommons.TotalModuleNumber); // All Test Modules in the Omicron test file. // TestModules testModules = this.OmicronDocument.TestModules; // Parallel.For (fromInclusive Int32, toExclusive Int32, parallelOptions, body) // TotalModelNumber IS EXCLUSIVE SO MUST ADD 1 TO IT. // Otherwise the last Test Module will never be processed. Parallel.For(startPosition, MyCommons.TotalModuleNumber + 1, MyCommons.ParallelingOptions, testModule => { // increment counter to open next test module. Interlocked.Add(ref moduleCounter, 1); OmicronProgramId = OmicronDocument.OLEObjects.get_Item(moduleCounter).ProgID; OmicronProgramName = OmicronDocument.OLEObjects.get_Item(moduleCounter).Name; // update current module number. // MyCommons.CurrentModuleNumber = testModule; MyCommons.CurrentModuleNumber = moduleCounter; MyCommons.MyViewModel.UpdateCommand.Execute(null); Debug.WriteLine(string.Format("{0}", new String(Settings.Default.RepeatChar, Settings.Default.RepeatNumber))); Debug.WriteLine(string.Format("SCAN PARALLEL thread: {0}", Thread.CurrentThread.GetHashCode())); Debug.WriteLine(string.Format("Test module name...: {0}", OmicronProgramName)); Debug.WriteLine(string.Format("Test module type...: {0}", OmicronProgramId)); Debug.WriteLine(string.Format("{0}", new String(Settings.Default.RepeatChar, Settings.Default.RepeatNumber))); Debug.WriteLine("Making a decision if the user wants to delete this test module....."); // REMOVE named Module(s) if (ItemsToRemove.TryGetValue(OmicronProgramName, out string tempValue)) { if (tempValue == OmicronProgramId) { Debug.WriteLine(string.Format("Deleting ProgID {0}\tand Name: {1}", OmicronProgramId, OmicronProgramName)); Debug.WriteLine(" ... TEST MODULE MARK FOR DELETION ...."); OmicronDocument.OLEObjects.get_Item(moduleCounter).Delete(); // just deleted a test module. Omicron updates total test module counter. // this is the reason for the decrement. Interlocked.Decrement(ref moduleCounter); // Show detailed output if the user wants it. if (Settings.Default.ShowDetailedOutput) { // Update DetailsTextBoxText. MyCommons.MyViewModel.DetailsTextBoxText = MyCommons.LogProcess.Append( string.Format( CultureInfo.InvariantCulture, MyResources.Strings_RemoveTM, OmicronProgramName, OmicronProgramId, Environment.NewLine)) .ToString(); } } } // store old title string title = OmicronDocument.OLEObjects.get_Item(moduleCounter).Name; Debug.WriteLine($"--------------------------> old title: {title}"); // update title. OmicronDocument.OLEObjects.get_Item(moduleCounter).Name = new AnalyzeValues().Change(input: title, pattern: new AnalyzeValues().TitlePatterns, keywords: new AnalyzeValues().TitleKeywords); // temp storage to keep replacement words. if (new AnalyzeValues().IsMatch(title, new AnalyzeValues().ProfilePatterns)) { string keywords = new AnalyzeValues().Match(input: title, pattern: new AnalyzeValues().ProfilePatterns); string replacementTitle = System.Text.RegularExpressions.Regex.Split(input: keywords, pattern: "(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)", options: System.Text.RegularExpressions.RegexOptions.None, matchTimeout: TimeSpan.FromMilliseconds(100))[0]; Dictionary <string, string> what = new Dictionary <string, string>() { { keywords, $"{replacementTitle}{activeProfile}" } }; string newTitle = new AnalyzeValues().Change(input: title, pattern: new AnalyzeValues().ProfilePatterns, keywords: what); // System.Text.RegularExpressions.Regex.Replace(input: title, pattern: "(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)", replacement: replacementTitle); Debug.WriteLine($"--------------------------> keywords: {keywords}, replacementTitle: {replacementTitle}, newTitle: {newTitle}"); OmicronDocument.OLEObjects.get_Item(moduleCounter).Name = newTitle; } Debug.WriteLine($"--------------------------> new title: {OmicronDocument.OLEObjects.get_Item(moduleCounter).Name} "); Debug.WriteLine($"--------------------------> group mod: {(Convert.ToBoolean(UseDefaultSettingBehavior) ? "Using Settings" : "Using Tests")}"); // Categorize Omicron Modules if (OmicronDocument.OLEObjects.get_Item(moduleCounter).IsTestModule) { TestModule currentModule = OmicronDocument.OLEObjects.get_Item(moduleCounter).TestModule; //testModules.Item[moduleCounter]; //// update current test module title if needed. // currentModule.Name = new AnalyzeValues().Change(input: currentModule.Name, pattern: new AnalyzeValues().TitlePatterns, keywords: new AnalyzeValues().TitleKeywords); Debug.WriteLine(" .... NO DELETION REQUIRED ...."); switch (OmicronProgramId) { case ProgId.Execute: try { // Polling CancellationToken's status. // If cancellation requested throw error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } Debug.WriteLine("--- Add option to modify 'Title' --- DONE"); Debug.WriteLine("--- Add option to modify 'Path' --- DONE"); Debug.WriteLine("--- Add option to modify 'Execution Options' ---"); Debug.WriteLine("--- as of 10/30/2018 ---"); Debug.WriteLine($"--------------------------> group mod: {(Convert.ToBoolean(UseDefaultSettingBehavior) ? "Using Settings" : "Using Tests")}"); // Retrieve parameters and save. Retrieve(currentModule); } catch (AggregateException ae) { foreach (Exception ex in ae.InnerExceptions) { // Save to the fileOutputFolder and print to Debug window if the project build is in Debug. ErrorHandler.Log(ex, CurrentFileName); } return; } break; case ProgId.OMRamp: try { // Polling CancellationToken's status. // If cancellation requested throw error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } Debug.WriteLine("--- Future use object 'Ramping Test Module' ---"); Debug.WriteLine("--- Add options to link each item to 'XRio Block' ---"); Debug.WriteLine("--- Add option to modify 'Title' ---"); Debug.WriteLine("--- as of 10/30/2018 ---"); //// update current test module title if needed. //currentModule.Name = new AnalyzeValues().Change(input: currentModule.Name, pattern: new AnalyzeValues().TitlePatterns, keywords: new AnalyzeValues().TitleKeywords); // Retrieve parameters and save. // Retrieve(currentTestModule); currentModule.Clear(); } catch (AggregateException ae) { foreach (Exception ex in ae.InnerExceptions) { // Save to the fileOutputFolder and print to Debug window if the project build is in Debug. ErrorHandler.Log(ex, CurrentFileName); } return; } break; case ProgId.OMSeq: try { // Polling CancellationToken's status. // If cancellation requested throw error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } Debug.WriteLine("--- Future use object 'State Sequencer Test Module' ---"); Debug.WriteLine("--- Add options to link each item to 'XRio Block' ---"); Debug.WriteLine("--- Add option to modify 'Title' ---"); Debug.WriteLine("--- as of 10/30/2018 ---"); // Retrieve parameters and save. // Retrieve(currentTestModule); currentModule.Clear(); } catch (AggregateException ae) { foreach (Exception ex in ae.InnerExceptions) { // Save to the fileOutputFolder and print to Debug window if the project build is in Debug. ErrorHandler.Log(ex, CurrentFileName); } return; } break; default: // Not supported test module. move on to the next module. break; } } else { Debug.WriteLine("--- NonTest object ---"); Debug.WriteLine(string.Format("Test module name...: {0}", OmicronProgramName)); Debug.WriteLine(string.Format("Test module type...: {0}", OmicronProgramId)); // it is not a Test Module. switch (OmicronProgramId) { case ProgId.XRio: // Polling CancellationToken's status. // If cancellation requested throw error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } Debug.WriteLine("--- Future use object 'XRio Block' ---"); Debug.WriteLine("--- Add option to modify 'Title' ---"); Debug.WriteLine("--- as of 10/30/2018 ---"); // future use. var xrio = OmicronDocument.OLEObjects.get_Item(moduleCounter); break; case ProgId.Hardware: // Polling CancellationToken's status. // If cancellation requested throw error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } Debug.WriteLine("--- Future use object 'Hardware Configuration' ---"); Debug.WriteLine("--- Add option to modify 'Title' ---"); Debug.WriteLine("--- as of 10/30/2018 ---"); break; case ProgId.Group: // Polling CancellationToken's status. // If cancellation requested throw error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } Debug.WriteLine("--- Future use object 'Groups' ---"); Debug.WriteLine("--- Add option to modify 'Title' ---"); Debug.WriteLine("--- as of 10/30/2018 ---"); Group group = OmicronDocument.OLEObjects.get_Item(moduleCounter).Group; UseDefaultSettingBehavior = new AnalyzeValues().IsMatch(group.Name, new AnalyzeValues().GroupFolderPatterns); // decide which behavior to use based on the folder name. if (Convert.ToBoolean(UseDefaultSettingBehavior)) { // true: Old method where point read and replaced per Execute parameters. ItemsToFind = new List <string>(ViewModel.FindWhatTextBoxText.Split('|')); ItemsToReplace = new List <string>(ViewModel.ReplaceWithTextBoxText.Split('|')); } else { // false: New method where point read is always Profile 1 and replaced per active Profile generating process ItemsToFind = new List <string>(MyCommons.FindProfile.Split('|')); ItemsToReplace = new List <string>(MyCommons.ReplaceProfile.Split('|')); } if (ItemsToFind.Count > 1) { Debug.WriteLine($"ItemsToFind: {ItemsToFind[5]}-{ItemsToFind[10]}-{ItemsToFind[15]}, ItemsToReplace: {ItemsToReplace[5]}-{ItemsToReplace[10]}-{ItemsToReplace[15]}"); } break; default: break; } } }); } catch (NullReferenceException ae) { ErrorHandler.Log(ae, CurrentFileName); return; } catch (OperationCanceledException ae) { ErrorHandler.Log(ae, CurrentFileName); return; } catch (AggregateException ae) { foreach (Exception ex in ae.InnerExceptions) { // Save to the fileOutputFolder and print to Debug window if the project build is in Debug. ErrorHandler.Log(ex, CurrentFileName); } return; } }
public int openTest(int testId, string studentTZ) { return(TestModule.openTest(testId, studentTZ)); }
public void disassemble_type_float() => TestModule.SafeImport(typeof(float)).Resolve() .Disassemble();
public void It_should_be_possible_to_parse_and_eval_script_with_modules() { var scriptService = new Moq.Mock<IScriptService>(); scriptService.Setup(p => p.Parse("TestModule.Name", Moq.It.IsAny<ScriptParameterList>())).Returns(new Mocks.ScriptExpressionMock("TestModule.Name", typeof(string))); TestModule testModule = new TestModule(); ModuleDefinitionList modules = new ModuleDefinitionList(); modules.Add(new ModuleDefinition("TestModule", TestModule.Definition)); PageParameterList parameters = new PageParameterList(); PageScriptService target = new PageScriptService(scriptService.Object); XValue exp; exp = target.Parse("@TestModule.Name", typeof(string), modules, parameters); scriptService.Verify(p => p.Parse("TestModule.Name", Moq.It.IsAny<ScriptParameterList>())); Dictionary<string, object> modulesInstance = new Dictionary<string, object>(); modulesInstance.Add("TestModule", testModule); ContextParameterList parametersInstance = new ContextParameterList(); target.Eval(exp, modulesInstance, parametersInstance); scriptService.Verify(p => p.Eval(Moq.It.IsAny<IScriptExpression>(), Moq.It.IsAny<ScriptParameterList>())); }
public void Calls_multiple_module_functions_when_successful_completion() { int callOrder = 0; int module1BeforeCalled = 0; int module1AfterCalled = 0; int module1ErrorCalled = 0; Exception module1Error = null; int module1FinishedCalled = 0; int module2BeforeCalled = 0; int module2AfterCalled = 0; int module2ErrorCalled = 0; Exception module2Error = null; int module2FinishedCalled = 0; int module3BeforeCalled = 0; int module3AfterCalled = 0; int module3ErrorCalled = 0; Exception module3Error = null; int module3FinishedCalled = 0; var module1 = new TestModule { BeforeCallback = delegate { module1BeforeCalled = ++callOrder; }, AfterCallback = delegate { module1AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module1ErrorCalled = ++callOrder; module1Error = ex; }, FinishedCallback = delegate { module1FinishedCalled = ++callOrder; }, }; var module2 = new TestModule { BeforeCallback = delegate { module2BeforeCalled = ++callOrder; }, AfterCallback = delegate { module2AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module2ErrorCalled = ++callOrder; module2Error = ex; }, FinishedCallback = delegate { module2FinishedCalled = ++callOrder; }, }; var module3 = new TestModule { BeforeCallback = delegate { module3BeforeCalled = ++callOrder; }, AfterCallback = delegate { module3AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module3ErrorCalled = ++callOrder; module3Error = ex; }, FinishedCallback = delegate { module3FinishedCalled = ++callOrder; }, }; var action = WorkerAction.Define() .DoWork(delegate { }) .AddModule(module1) .AddModule(module2) .AddModule(module3) .Create(); action.Run(); Assert.AreEqual(1, module1BeforeCalled); Assert.AreEqual(2, module2BeforeCalled); Assert.AreEqual(3, module3BeforeCalled); Assert.AreEqual(4, module3AfterCalled); Assert.AreEqual(5, module2AfterCalled); Assert.AreEqual(6, module1AfterCalled); Assert.AreEqual(0, module3ErrorCalled); Assert.IsNull(module3Error); Assert.AreEqual(0, module2ErrorCalled); Assert.IsNull(module2Error); Assert.AreEqual(0, module1ErrorCalled); Assert.IsNull(module1Error); Assert.AreEqual(7, module3FinishedCalled); Assert.AreEqual(8, module2FinishedCalled); Assert.AreEqual(9, module1FinishedCalled); }
public void ConfigureUsingXmlApplicationContext() { XmlApplicationContext appContext = new XmlApplicationContext(false, ReadOnlyXmlTestResource.GetFilePath("HttpApplicationConfigurerTests.xml", typeof(HttpApplicationConfigurerTests))); TestModule m1 = new TestModule(); TestModule m2 = new TestModule(); TestApplication appObject = new TestApplication(new ModuleEntry[] { new ModuleEntry("TestModule1", m1) , new ModuleEntry("TestModule2", m2), }); HttpApplicationConfigurer.Configure(appContext, appObject); // app configured Assert.AreEqual(appContext.GetObject("testObject"), appObject.TestObject); // modules configured Assert.AreEqual(appContext.GetObject("testObject1"), m1.TestObject); Assert.AreEqual(null, m2.TestObject); }
public void Calls_multiple_module_functions_when_exception_thrown_by_Module_finished() { int callOrder = 0; Exception errorExceptionThrown = null; int module1BeforeCalled = 0; int module1AfterCalled = 0; int module1ErrorCalled = 0; Exception module1Error = null; int module1FinishedCalled = 0; int module2BeforeCalled = 0; int module2AfterCalled = 0; int module2ErrorCalled = 0; Exception module2Error = null; int module2FinishedCalled = 0; int module3BeforeCalled = 0; int module3AfterCalled = 0; int module3ErrorCalled = 0; Exception module3Error = null; int module3FinishedCalled = 0; bool doWorkCalled = false; var module1 = new TestModule { BeforeCallback = delegate { module1BeforeCalled = ++callOrder; }, AfterCallback = delegate { module1AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module1ErrorCalled = ++callOrder; module1Error = ex; }, FinishedCallback = delegate { module1FinishedCalled = ++callOrder; }, }; var module2 = new TestModule { BeforeCallback = delegate { module2BeforeCalled = ++callOrder; }, AfterCallback = delegate { module2AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module2ErrorCalled = ++callOrder; module2Error = ex; }, FinishedCallback = delegate { module2FinishedCalled = ++callOrder; errorExceptionThrown = new ApplicationException("thrown by module"); throw errorExceptionThrown; }, }; var module3 = new TestModule { BeforeCallback = delegate { module3BeforeCalled = ++callOrder; }, AfterCallback = delegate { module3AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module3ErrorCalled = ++callOrder; module3Error = ex; }, FinishedCallback = delegate { module3FinishedCalled = ++callOrder; }, }; var action = WorkerAction.Define() .DoWork(delegate { doWorkCalled = true; }) .AddModule(module1) .AddModule(module2) .AddModule(module3) .Create(); action.Run(); Assert.AreEqual(1, module1BeforeCalled); Assert.AreEqual(2, module2BeforeCalled); Assert.AreEqual(3, module3BeforeCalled); Assert.AreEqual(4, module3AfterCalled); Assert.AreEqual(5, module2AfterCalled); Assert.AreEqual(6, module1AfterCalled); Assert.AreEqual(0, module3ErrorCalled); Assert.IsNull(module3Error); Assert.AreEqual(0, module2ErrorCalled); Assert.IsNull(module2Error); Assert.AreEqual(0, module1ErrorCalled); Assert.IsNull(module1Error); Assert.AreEqual(7, module3FinishedCalled); Assert.AreEqual(8, module2FinishedCalled); Assert.AreEqual(9, module1FinishedCalled); Assert.IsTrue(doWorkCalled); }
public void Calls_module_functions_when_exception_thrown() { int callOrder = 0; int module1BeforeCalled = 0; int module1AfterCalled = 0; int module1ErrorCalled = 0; Exception module1Error = null; int module1FinishedCalled = 0; var module1 = new TestModule { BeforeCallback = delegate { module1BeforeCalled = ++callOrder; }, AfterCallback = delegate { module1AfterCalled = ++callOrder; }, ErrorCallback = delegate(Exception ex) { module1ErrorCalled = ++callOrder; module1Error = ex; }, FinishedCallback = delegate { module1FinishedCalled = ++callOrder; }, }; var action = WorkerAction.Define() .DoWork(delegate { throw new ApplicationException("test exception"); }) .AddModule(module1) .Create(); action.Run(); Assert.AreEqual(1, module1BeforeCalled); Assert.AreEqual(0, module1AfterCalled); Assert.AreEqual(2, module1ErrorCalled); Assert.IsNotNull(module1Error); Assert.AreEqual(3, module1FinishedCalled); }
public void import_system_typeinfo() => TestModule .SafeImport(typeof(XNode).GetTypeInfo()) .Should().Not.Be.Null();