public void Should_Resolve_Url() { // Given const string url = "http://google.com/"; var urlResolver = new FakeRuleUrlResolver(); urlResolver.AddUrlResolver(x => new Uri(url)); // When var ruleUrl = urlResolver.ResolveRuleUrl("foo"); // Then ruleUrl.ToString().ShouldBe(url); }
public void Should_Return_Null_If_No_Resolver_Was_Found() { // Given const string foo = "foo"; const string fooUrl = "http://foo.com/"; var urlResolver = new FakeRuleUrlResolver(); urlResolver.AddUrlResolver(x => x.Rule == foo ? new Uri(fooUrl) : null); // When var result = urlResolver.ResolveRuleUrl("bar"); // Then result.ShouldBeNull(); }
public void Should_Take_Priority_Into_Account(int secondPriority, string expectedUrl) { // Given const string fooUrl = "http://foo.com/"; const string barUrl = "http://bar.com/"; var urlResolver = new FakeRuleUrlResolver(); urlResolver.AddUrlResolver(x => new Uri(fooUrl), 0); urlResolver.AddUrlResolver(x => new Uri(barUrl), secondPriority); // When var result = urlResolver.ResolveRuleUrl("foo"); // Then result.ToString().ShouldBe(expectedUrl); }
public void Should_Resolve_Url_With_Multiple_Resolvers() { // Given const string foo = "foo"; const string fooUrl = "http://foo.com/"; const string bar = "bar"; const string barUrl = "http://bar.com/"; var urlResolver = new FakeRuleUrlResolver(); urlResolver.AddUrlResolver(x => x.Rule == foo ? new Uri(fooUrl) : null); urlResolver.AddUrlResolver(x => x.Rule == bar ? new Uri(barUrl) : null); // When var fooRuleUrl = urlResolver.ResolveRuleUrl(foo); var barRuleUrl = urlResolver.ResolveRuleUrl(bar); // Then fooRuleUrl.ToString().ShouldBe(fooUrl); barRuleUrl.ToString().ShouldBe(barUrl); }