public void Test_Locate_Wildcards() { //StrategyStateNameValueCollection strategies = new StrategyStateNameValueCollection(); //strategies.Clear(); //strategies.Add(typeof(AuthoriseReferenceMockPublicEntityStrategy)); AuthoriseReferenceStrategyLocator locator = new AuthoriseReferenceStrategyLocator(StrategyState.Strategies); StrategyInfo strategy = locator.Locate("TestArticle", "PublicEntities", "TestCategory", String.Empty); Assert.IsNotNull(strategy, "No strategy found."); string expectedType = typeof(AuthoriseReferenceStrategy).FullName + ", " + typeof(AuthoriseReferenceStrategy).Assembly.GetName().Name; Assert.AreEqual(expectedType, strategy.StrategyType, "Wrong strategy info located."); }
public void Test_Locate_Basic_MockEntity_PublicEntities_MockPublicEntity() { StrategyStateNameValueCollection strategies = new StrategyStateNameValueCollection(); strategies.Clear(); strategies.Add(typeof(AuthoriseReferenceMockPublicEntityStrategy)); AuthoriseReferenceStrategyLocator locator = new AuthoriseReferenceStrategyLocator(strategies); StrategyInfo strategy = locator.Locate("MockEntity", "PublicEntities", "MockPublicEntity", String.Empty); Assert.IsNotNull(strategy, "No strategy found."); string expectedType = typeof(AuthoriseReferenceMockPublicEntityStrategy).FullName + ", " + typeof(AuthoriseReferenceMockPublicEntityStrategy).Assembly.GetName().Name; Assert.AreEqual(expectedType, strategy.StrategyType, "Wrong strategy info located."); }
/// <summary> /// Creates a new authorise reference strategy. /// </summary> /// <param name="typeName"></param> /// <returns></returns> public IAuthoriseReferenceStrategy NewReferenceAuthoriser(string typeName1, string propertyName1, string typeName2, string propertyName2) { IAuthoriseReferenceStrategy strategy = null; using (LogGroup logGroup = LogGroup.StartDebug("Creating a new authorise reference strategy.")) { LogWriter.Debug("Type name 1: " + typeName1); LogWriter.Debug("Property name 1: " + propertyName1); LogWriter.Debug("Type name 2: " + typeName2); LogWriter.Debug("Property name 2: " + propertyName2); AuthoriseReferenceStrategyLocator locator = new AuthoriseReferenceStrategyLocator(StrategyState.Strategies); StrategyInfo strategyInfo = locator.Locate(typeName1, propertyName1, typeName2, propertyName2); if (strategyInfo != null) { strategy = strategyInfo.New <IAuthoriseReferenceStrategy>(); } } return(strategy); }