示例#1
0
            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)));
            }
示例#2
0
            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)));
            }
示例#3
0
            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);
            }
示例#4
0
            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);
            }
示例#5
0
            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);
            }