示例#1
0
        public async Task <IActionResult> Get([FromRoute] GetFromRoute route,
                                              [FromQuery] GetFromQuery query)
        {
            var request = new GetRequest(route, query);

            var result = await _apiResult.Produce(request);

            return(result);
        }
示例#2
0
        public void ConstructorShouldFailWhenQueryIsNull()
        {
            // Arrange
            var          route = new GetFromRoute();
            GetFromQuery query = null;

            // Act
            Action ctor = () => { new GetRequest(route, query); };

            // Assert
            ctor.Should().Throw <ArgumentNullException>();
        }
示例#3
0
        public void ConstructorShouldSucceed()
        {
            // Arrange
            var route = new GetFromRoute();
            var query = new GetFromQuery();


            // Act
            var obj = new GetRequest(route, query);

            // Assert
            obj.Should().NotBeNull();
        }
示例#4
0
        public void MemberQueryApiVersionShouldHaveCorrectValue()
        {
            // Arrange
            var apiVersion = "1.0";
            var route      = new GetFromRoute();
            var query      = new GetFromQuery()
            {
                ApiVersion = apiVersion
            };

            // Act
            var obj = new GetRequest(route, query);

            // Assert
            obj.QueryApiVersion.Should().Be(apiVersion);
        }
示例#5
0
        public void MemberRouteIdShouldHaveCorrectValue()
        {
            // Arrange
            var routeId = Guid.NewGuid().ToString();
            var route   = new GetFromRoute()
            {
                Id = routeId
            };
            var query = new GetFromQuery();

            // Act
            var obj = new GetRequest(route, query);

            // Assert
            obj.RouteId.Should().Be(routeId);
        }
示例#6
0
 public GetRequest(GetFromRoute route, GetFromQuery query)
 {
     _route = route ?? throw new ArgumentNullException(nameof(route));
     _query = query ?? throw new ArgumentNullException(nameof(query));
 }