public void Throws_InvalidOperationException_When_QueryStringCollection_Has_Less_Input_Than_Expected() { // Arrange var requestCommand = new FakeNameRequestCommand { Name = "foo" }; // Assert Assert.Throws<InvalidOperationException>(() => // Act UriUtil.ResolveUriTemplate( "api/cars?name={name}&surname={surname}", new QueryStringCollection(requestCommand))); }
public void Throws_InvalidOperationException_When_QueryStringCollection_Has_Less_Input_Than_Expected() { // Arrange var requestCommand = new FakeNameRequestCommand { Name = "foo" }; // Assert Assert.Throws <InvalidOperationException>(() => // Act UriUtil.ResolveUriTemplate( "api/cars?name={name}&surname={surname}", new QueryStringCollection(requestCommand))); }
public void Returns_The_Expected_Uri_When_The_Inputs_Valid_With_No_Id() { // Arrange var requestCommand = new FakeNameRequestCommand { Name = "foo" }; // Act var requestUri = UriUtil.ResolveUriTemplate<string>( "api/cars?name={name}", null, new QueryStringCollection(requestCommand)); // Assert Assert.Equal(string.Format("api/cars?name={0}", requestCommand.Name.ToLowerInvariant()), requestUri, StringComparer.InvariantCulture); }
public void Returns_The_Expected_Uri_When_The_Inputs_Valid() { // Arrange var id = Guid.NewGuid().ToString(); var requestCommand = new FakeNameRequestCommand { Name = "foo" }; // Act var requestUri = UriUtil.ResolveUriTemplate( "api/cars/{id}?name={name}", id, new QueryStringCollection(requestCommand)); // Assert Assert.Equal(string.Format("api/cars/{0}?name={1}", id, requestCommand.Name.ToLowerInvariant()), requestUri, StringComparer.InvariantCulture); }
public void Returns_The_Expected_Uri_When_The_Inputs_Valid() { // Arrange var id = Guid.NewGuid().ToString(); var requestCommand = new FakeNameRequestCommand { Name = "foo" }; var parameters = new { id = id, name = requestCommand.Name }; // Act var requestUri = UriUtil.ResolveUriTemplate( "api/cars/{id}?name={name}", new QueryStringCollection(parameters)); // Assert Assert.Equal(string.Format("api/cars/{0}?name={1}", id, requestCommand.Name.ToLowerInvariant()), requestUri, StringComparer.InvariantCulture); }