Esempio n. 1
0
        public void Test_this_StrategyNotFound()
        {
            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string action = "MockAction";
            string type   = "MockType";

            StrategyInfo notFoundStrategy = collection[action + "Mismatch", type];
        }
        public void Test_this_StrategyNotFound()
        {
            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string action = "MockAction";
            string type = "MockType";

            StrategyInfo notFoundStrategy = collection[action + "Mismatch", type];
        }
        public void Test_this_Interface_StrategyNotFound()
        {
            StrategyInfo testStrategy = StrategyInfo.ExtractInfo(typeof(SaveStrategy))[0];

            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string type = "TestUser";
            string action = "TestAction";

            collection[action, type] = testStrategy;

            StrategyInfo notFoundStrategy = collection[action + "Mismatch", type];

            Assert.IsNull(notFoundStrategy);
        }
        public void Test_this_Interface()
        {
            StrategyInfo testStrategy = StrategyInfo.ExtractInfo(typeof(RetrieveStrategy))[0];

            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string type = "TestArticle";
            string action = "Retrieve";

            collection.Add(testStrategy);

            StrategyInfo foundStrategy = collection[action, type];

            Assert.IsNotNull(foundStrategy);
        }
        public void Test_this()
        {
            StrategyInfo testStrategy = StrategyInfo.ExtractInfo(typeof(MockRetrieveTestUserStrategy))[0];

            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string type = "TestUser";
            string action = "Retrieve";

            collection.Add(testStrategy);

            StrategyInfo foundStrategy = collection[action, type];

            Assert.IsNotNull(foundStrategy, "Strategy not found.");
        }
Esempio n. 6
0
        public void Test_this_Interface_StrategyNotFound()
        {
            StrategyInfo testStrategy = StrategyInfo.ExtractInfo(typeof(SaveStrategy))[0];

            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string type   = "TestUser";
            string action = "TestAction";

            collection[action, type] = testStrategy;

            StrategyInfo notFoundStrategy = collection[action + "Mismatch", type];

            Assert.IsNull(notFoundStrategy);
        }
Esempio n. 7
0
        public void Test_this_Interface()
        {
            StrategyInfo testStrategy = StrategyInfo.ExtractInfo(typeof(RetrieveStrategy))[0];

            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string type   = "TestArticle";
            string action = "Retrieve";

            collection.Add(testStrategy);

            StrategyInfo foundStrategy = collection[action, type];

            Assert.IsNotNull(foundStrategy);
        }
Esempio n. 8
0
        public void Test_this()
        {
            StrategyInfo testStrategy = StrategyInfo.ExtractInfo(typeof(MockRetrieveTestUserStrategy))[0];

            StrategyStateNameValueCollection collection = new StrategyStateNameValueCollection();

            string type   = "TestUser";
            string action = "Retrieve";

            collection.Add(testStrategy);

            StrategyInfo foundStrategy = collection[action, type];

            Assert.IsNotNull(foundStrategy, "Strategy not found.");
        }
Esempio n. 9
0
        /// <summary>
        /// Tests the LocateFromInterfaces method where the matching interface is implemented by a base type.
        /// </summary>
        public void Test_LocateFromInterfaces_Heirarchy()
        {
            Type   type   = typeof(TestArticle);
            string action = "Save";

            StrategyStateNameValueCollection strategies = new StrategyStateNameValueCollection();

            strategies.Add(typeof(SaveStrategy));             // Save-IEntity
            strategies.Add(typeof(UpdateStrategy));           // Update-IEntity

            StrategyLocator locator = new StrategyLocator(strategies);

            StrategyInfo info = locator.LocateFromInterfaces(action, type);

            Assert.IsNotNull(info, "No strategy info found.");
        }
        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.");
        }
        public void Test_LocateFromInterfaces_Immediate()
        {
            Type type = typeof(IEntity);
            string action = "Save";

            StrategyStateNameValueCollection strategies = new StrategyStateNameValueCollection();

            strategies.Add(typeof(SaveStrategy));
            strategies.Add(typeof(UpdateStrategy));

            StrategyLocator locator = new StrategyLocator(strategies);

            StrategyInfo info = locator.LocateFromInterfaces(action,type);

            Assert.IsNotNull(info, "No strategy info found.");
        }
        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.");
        }
Esempio n. 13
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.");
        }
Esempio n. 14
0
 /// <summary>
 /// Sets the provided strategies to the Strategies property.
 /// </summary>
 /// <param name="strategies"></param>
 public StrategyLocator(StrategyStateNameValueCollection strategies)
 {
     Strategies = strategies;
 }
        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.");
        }
 /// <summary>
 /// Sets the provided strategies to the Strategies property.
 /// </summary>
 /// <param name="strategies"></param>
 public AuthoriseReferenceStrategyLocator(StrategyStateNameValueCollection strategies)
 {
     Strategies = strategies;
 }