public void CanFetchAndExecuteFilter() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\Plugins\bin\Debug\Plugins.dll"; var filterRegistry = new FilterRegistry<Step>(); filterRegistry.LoadPlugIn(source); var filters = filterRegistry.GetFilters("Plugins.CaptainUnfitForCommandFilter") .ToList(); Assert.AreEqual(1, filters.Count); var parameters = new Dictionary<string, object>(); parameters.Add("KirkInfected", true); var step = new Step("12w", "231a", "CaptainApproval", "FirstOfficeReview", "Deny", DateTime.Now, "Kirk", "Kirk", parameters); step.CanProcess = true; step = filters[0].Execute(step); Assert.AreEqual(false, step.CanProcess); Assert.AreEqual(1, step.ErrorList.Count); Assert.IsTrue((bool)step.Parameters["MedicalOverride"]); Console.WriteLine(step.ErrorList[0]); }
public void AddThenGetMatchesOneFilterOfOneType() { FakeUnityContainer container = new FakeUnityContainer(); container.Add(new FakeActionFilter()); FilterRegistry registry = new FilterRegistry(container); registry.Add(new[] { new FakeFilterCriteria() { IsMatch = true } }, typeof(FakeActionFilter)); FilterInfo filters = registry.GetFilters(this.GetFakeContext()); Assert.Equal(1, filters.ActionFilters.Count); Assert.IsType <FakeActionFilter>(filters.ActionFilters[0]); Assert.Equal(0, filters.AuthorizationFilters.Count); Assert.Equal(0, filters.ExceptionFilters.Count); Assert.Equal(0, filters.ResultFilters.Count); }