public void NavigationParser_Parsing_InvalidSegment() { var parser = new NavigationUrlParser("/Main/Detail/03?a1=E%20R&a2=5&a3=True"); Assert.IsFalse(parser.WithSegment("Main") .WithSegment("Woops") .IsSuccess); }
public void NavigationParser_Parsing_InvalidDynamicSegment() { var parser = new NavigationUrlParser("/Main/Detail/03?a1=E%20R&a2=5&a3=True"); Assert.IsFalse(parser.WithSegment("Main") .WithSegment("Detail") .WithDynamicSegment(out bool badType) .IsSuccess); }
public void NavigationParser_Parsing_MissingOptionalQueryArgument() { var parser = new NavigationUrlParser("/Main/Detail/03?a1=E%20R&a2=5&a3=True"); Assert.IsTrue(parser.WithSegment("Main") .WithSegment("Detail") .WithDynamicSegment(out int id) .WithQuery((q) => q.WithOptional("missing", (string missing) => { })) .IsSuccess); }
public void NavigationParser_Parsing_GuidArgument() { string part1 = "part1", part2 = "part2", part3 = "part3"; Guid guidPart = Guid.NewGuid(); var parser = new NavigationUrlParser($"{part1}/{part2}/{guidPart}/{part3}/"); var result = parser.WithSegment(part1) .WithSegment(part2) .WithDynamicSegment(out System.Guid parsedGuid) .WithSegment(part3); Assert.IsTrue(result.IsSuccess); Assert.AreEqual(guidPart, parsedGuid); }
public void NavigationParser_Parsing_ValidUrl() { var parser = new NavigationUrlParser("/Main/Detail/03?a1=E%20R&a2=5&a3=True"); string a1 = null; int a2 = 0; bool a3 = false; Assert.IsTrue(parser.WithSegment("Main") .WithSegment("Detail") .WithDynamicSegment(out int id) .WithQuery((q) => q.WithRequired("a1", out a1).WithRequired("a2", out a2).WithRequired("a3", out a3)) .IsSuccess); Assert.AreEqual(3, id); Assert.AreEqual("E R", a1); Assert.AreEqual(5, a2); Assert.AreEqual(true, a3); }