示例#1
0
        public void Venue_VenueServiceApi_GetVenues_IfSuccess_ReturnsVenues()
        {
            var venues = new List <SDK.Venue.Models.Venue> {
                new SDK.Venue.Models.Venue(), new SDK.Venue.Models.Venue()
            };

            executorMock
            .Setup(x => x
                   .ExecuteApiWithWrappedResponse <List <SDK.Venue.Models.Venue>, VenuesResponse, VenuesResponseContent>(
                       It.IsAny <string>(),
                       It.IsAny <RequestMethod>(),
                       null,
                       null,
                       null,
                       true))
            .Returns(() => new ApiResult <List <SDK.Venue.Models.Venue> >(
                         venues,
                         TestHelper.GetSuccessResponse(),
                         It.IsAny <ApiContext>(),
                         It.IsAny <Context>(),
                         It.IsAny <Request>()));

            var result = GetVenues();

            executorMock.Verify(mock =>
                                mock.ExecuteApiWithWrappedResponse <List <SDK.Venue.Models.Venue>, VenuesResponse, VenuesResponseContent>(
                                    It.IsAny <string>(),
                                    It.IsAny <RequestMethod>(),
                                    null,
                                    null,
                                    null,
                                    true), Times.Once);
            AssertExtension.EnumerableAreEquals(venues, result.ToList());
        }
示例#2
0
        public void Venue_VenueServiceApi_GetSeatAttributesByVenue_IfSuccess_Works()
        {
            const string venueId        = "3456";
            var          seatAttributes = new List <SeatAttribute> {
                new SeatAttribute(), new SeatAttribute()
            };

            executorMock
            .Setup(x => x.ExecuteApiWithWrappedResponse <List <SeatAttribute> >(
                       It.IsAny <string>(),
                       It.IsAny <RequestMethod>(),
                       null,
                       null,
                       null,
                       true))
            .Returns(() => new ApiResult <List <SeatAttribute> >(
                         seatAttributes,
                         TestHelper.GetSuccessResponse(),
                         It.IsAny <ApiContext>(),
                         It.IsAny <Context>(),
                         It.IsAny <Request>()));

            var result = GetSeatAttributes(new SDK.Venue.Models.Venue {
                internalId = venueId
            });

            executorMock.Verify(mock => mock.ExecuteApiWithWrappedResponse <List <SeatAttribute> >(
                                    It.Is <string>(x => x.Contains(venueId)),
                                    It.IsAny <RequestMethod>(),
                                    null,
                                    null,
                                    null,
                                    true), Times.Once);
            AssertExtension.EnumerableAreEquals(seatAttributes, result.ToList());
        }
        public void Api_ApiClientWrapperBuilder_CreateClientWrapperParameters_ReturnsCorrectedParameters(
            ApiContext context, RequestMethod method, object queryObject,
            Dictionary <string, string> expectedHeaders, Dictionary <string, string> expectedQuery)
        {
            var baseUrl            = It.IsAny <string>();
            var endpoint           = It.IsAny <string>();
            var body               = It.IsAny <object>();
            var dateFormat         = It.IsAny <string>();
            var expectedParameters = new RestClientParameters
            {
                BaseUrl            = baseUrl,
                RequestUrl         = endpoint,
                RequestBody        = body,
                RequestFormat      = RequestFormat.Json,
                RequestMethod      = method,
                RequestUrlSegments = null,
                RequestDateFormat  = dateFormat
            };
            var result = ApiClientWrapperBuilder.CreateClientWrapperParameters(context, baseUrl, endpoint, method, body,
                                                                               queryObject, dateFormat);

            AssertExtension.SimplePropertyValuesAreEquals(expectedParameters, result);
            AssertExtension.EnumerableAreEquals(expectedParameters.RequestUrlSegments, result.RequestUrlSegments);
            AssertExtension.EnumerableAreEquals(expectedParameters.RequestQueryParameters, expectedQuery);
            AssertExtension.EnumerableAreEquals(expectedParameters.RequestHeaders, expectedHeaders);
        }
        public void Api_ApiException_DetailsProperty_ReturnsCorrectValue(Dictionary <string, object> expected, Request request)
        {
            var exception =
                new ApiException(It.IsAny <RestResponse>(), It.IsAny <ApiContext>(), It.IsAny <Context>(), request);

            var result = exception.Details;

            AssertExtension.EnumerableAreEquals(expected, result);
        }
        public void Api_ApiException_ErrorsProperty_ReturnsCorrectValue(List <string> expectedErrors, IRestResponse response, Context context)
        {
            var exception =
                new ApiException(response, It.IsAny <ApiContext>(), context, It.IsAny <Request>());

            var result = exception.Errors;

            AssertExtension.EnumerableAreEquals(expectedErrors, result);
        }