コード例 #1
0
        public void Test_Locate_Base_Save()
        {
            StrategyLocator locator = new StrategyLocator(StrategyState.Strategies);

            StrategyInfo info = locator.Locate("Save", "IEntity");

            string expectedType = typeof(SaveStrategy).FullName + ", " + typeof(SaveStrategy).Assembly.GetName().Name;

            Assert.AreEqual(expectedType, info.StrategyType, "Wrong strategy located.");
        }
コード例 #2
0
        public void Test_Locate()
        {
            StrategyLocator locator = new StrategyLocator(StrategyState.Strategies);

            StrategyInfo info = locator.Locate("Delete", "TestArticle");

            string expectedType = typeof(DeleteStrategy).FullName + ", " + typeof(DeleteStrategy).Assembly.GetName().Name;

            Assert.AreEqual(expectedType, info.StrategyType, "Wrong strategy located.");
        }
コード例 #3
0
        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.");
        }