public void Combine_InvalidTemplates(string left, string right, string expected) { // Arrange & Act var combined = AttributeRouteTemplate.Combine(left, right); // Assert Assert.Equal(expected, combined); }
public void ReplaceTokens_ValidValues(string template, object values, string expected) { // Arrange var valuesDictionary = values as IDictionary <string, object>; if (valuesDictionary == null) { valuesDictionary = new RouteValueDictionary(values); } // Act var result = AttributeRouteTemplate.ReplaceTokens(template, valuesDictionary); // Assert Assert.Equal(expected, result); }
public void ReplaceTokens_InvalidFormat(string template, object values, string reason) { // Arrange var valuesDictionary = values as IDictionary <string, object>; if (valuesDictionary == null) { valuesDictionary = new RouteValueDictionary(values); } var expected = string.Format( "The route template '{0}' has invalid syntax. {1}", template, reason); // Act var ex = Assert.Throws <InvalidOperationException>( () => { AttributeRouteTemplate.ReplaceTokens(template, valuesDictionary); }); // Assert Assert.Equal(expected, ex.Message); }
public void ReplaceTokens_UnknownValue() { // Arrange var template = "[area]/[controller]/[action2]"; var values = new RouteValueDictionary() { { "area", "Help" }, { "controller", "Admin" }, { "action", "SeeUsers" }, }; var expected = "While processing template '[area]/[controller]/[action2]', " + "a replacement value for the token 'action2' could not be found. " + "Available tokens: 'area, controller, action'."; // Act var ex = Assert.Throws <InvalidOperationException>( () => { AttributeRouteTemplate.ReplaceTokens(template, values); }); // Assert Assert.Equal(expected, ex.Message); }