public void Test_ExtractInfo() { MockIndexWidgetStrategy strategy = new MockIndexWidgetStrategy(); StrategyInfo info = StrategyInfo.ExtractInfo(strategy.GetType())[0]; Assert.AreEqual("Widget", info.TypeName, "Type name doesn't match what's expected."); Assert.AreEqual("Index", info.Action, "Action doesn't match what's expected."); //Assert.AreEqual("Index_Widget", info.Key, "Key doesn't match what's expected."); Assert.AreEqual(strategy.GetType().FullName + ", " + strategy.GetType().Assembly.GetName().Name, info.StrategyType, "Strategy type doesn't match what's expected."); }
public void Test_Locate_CustomOverride() { string type = "Widget"; string action = "Index"; StrategyStateNameValueCollection strategies = new StrategyStateNameValueCollection(); strategies.Add(typeof(IndexStrategy)); strategies.Add(typeof(MockIndexWidgetStrategy)); StrategyLocator locator = new StrategyLocator(strategies); StrategyInfo info = locator.Locate(action, type); Assert.IsNotNull(info, "No strategy info found."); Type mockStrategyType = new MockIndexWidgetStrategy().GetType(); string expected = mockStrategyType.FullName + ", " + mockStrategyType.Assembly.GetName().Name; Assert.AreEqual(expected, info.StrategyType, "Wrong strategy type selected."); }