Skip to content

Instantly share code, notes, and snippets.

@ysw
Created Aug 27, 2012
Embed
What would you like to do?
UriTemplate mono bahvior tests
using System;
using System.Linq;
using NUnit.Framework;
namespace Core.Tests.Other
{
[TestFixture]
class when_matching_remaining_path
{
private UriTemplate _urlTemplate;
private UriTemplateMatch _match;
[SetUp]
public void setup()
{
_urlTemplate = new UriTemplate("/a/b/{*C}");
_match = _urlTemplate.Match(new Uri("http://localhost"), new Uri("http://localhost/a/b/123"));
}
[Test]
public void bound_variable_c_is_available()
{
Assert.IsTrue(_match.BoundVariables.AllKeys.Contains("C"));
}
[Test]
public void bound_variable_c_contains_remaining_path()
{
Assert.AreEqual("123", _match.BoundVariables["C"]);
}
}
[TestFixture]
class when_matching_remaining_multi_segment_path
{
private UriTemplate _urlTemplate;
private UriTemplateMatch _match;
[SetUp]
public void setup()
{
_urlTemplate = new UriTemplate("/a/b/{*C}");
_match = _urlTemplate.Match(new Uri("http://localhost"), new Uri("http://localhost/a/b/123/456"));
}
[Test]
public void bound_variable_c_is_available()
{
Assert.IsTrue(_match.BoundVariables.AllKeys.Contains("C"));
}
[Test]
public void bound_variable_c_contains_remaining_path()
{
Assert.AreEqual("123/456", _match.BoundVariables["C"]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment