public void IsNamespaceMatch(string testNamespace, bool expectedResult)
 {
     // Act & Assert
     Assert.Equal(
         expectedResult,
         ControllerTypeCache.IsNamespaceMatch(testNamespace, "Dummy.Controllers")
         );
 }
Ejemplo n.º 2
0
        public void IsNamespaceMatch()
        {
            // Arrange
            var tests = new[] {
                new { TestNamespace = (string)null, ExpectedResult = false, Reason = "Null requested namespace should not match any target namespace." },
                new { TestNamespace = "", ExpectedResult = true, Reason = "Empty requested namespace should match any target namespace." },
                new { TestNamespace = "Dummy.Controllers", ExpectedResult = true, Reason = "Exact matches between requested namespace and target namespace are valid." },
                new { TestNamespace = "Dummy", ExpectedResult = false, Reason = "Parent namespace matches between exact requested namespace and target namespace are invalid." },
                new { TestNamespace = "Dummy.Controller.*", ExpectedResult = false, Reason = "Wildcard namespace prefix did not match." },
                new { TestNamespace = "Dummy.Controllers.*", ExpectedResult = true, Reason = "Wildcard namespace prefix matched." },
                new { TestNamespace = "Dummy.*", ExpectedResult = true, Reason = "Wildcard namespace prefix matched." },
                new { TestNamespace = "Dummy.Controllers*", ExpectedResult = false, Reason = "Wildcard end token is incorrect ('*' vs. '.*')." }
            };

            // Act & assert
            foreach (var test in tests)
            {
                bool retVal = ControllerTypeCache.IsNamespaceMatch(test.TestNamespace, "Dummy.Controllers");
                Assert.AreEqual(test.ExpectedResult, retVal, test.Reason);
            }
        }