Skip to content

Instantly share code, notes, and snippets.

@ysw
Created August 27, 2012 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysw/3488351 to your computer and use it in GitHub Desktop.
Save ysw/3488351 to your computer and use it in GitHub Desktop.
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