Esempio n. 1
0
        public void PatternEngineUseAsLibrary()
        {
            var engine = new PatternEngine();

            engine.TryMatch("/category", "/category/cat1/product/prod1", out var match, out var why).Should().BeTrue();
            match.Should().NotBeNull();
            match !.PathSuffix.Should().Be("/cat1/product/prod1");
            why.Should().BeNull();
        }
Esempio n. 2
0
 public void TryMatchVariableNotPresentTest()
 {
     engine.TryMatch("/category/:catid(/product/:pid)", "/category/home", out var match, out var why).Should().BeTrue();
     match.Should().NotBeNull();
     match !.PathSuffix.Should().Be(string.Empty);
     match.Variables.Should().BeEquivalentTo(new Dictionary <string, string>()
     {
         ["catid"] = "home"
     });
     why.Should().BeNull();
 }
Esempio n. 3
0
        /// <summary>
        /// Appends the specified well known suffix type to a file name without
        /// modifying the extension.
        /// </summary>
        /// <param name="path">The file name on which to append the suffix.</param>
        /// <param name="suffixType">The suffix type to append.</param>
        /// <returns>
        /// The new file name where <paramref name="path"/> has been modified
        /// to end with the specified <paramref name="suffixType"/> but without
        /// modifying the file extension.
        /// </returns>
        public static string AppendSuffix(string path, PathSuffix suffixType)
        {
            switch (suffixType)
            {
            case PathSuffix.FileCount: return(AppendFileCount(path));

            case PathSuffix.Timestamp: return(AppendTimestamp(path, HighResolutionScheduler.Now));

            case PathSuffix.None:
            default: return(path);
            }
        }
        public void TryResolve_SimpleMatch_Success()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();

            httpContext.Request.Path = "/api/test/";

            // Act
            resolver.TryResolve(httpContext, out var route).Should().BeTrue();

            // Assert
            route.Should().NotBeNull();
            route !.PathSuffix.Should().Be("test/");
        }