public void CategoryGetByIdRequestMessage()
        {
            string apiBaseAddressWithProjectKey             = this.clientFixture.GetAPIBaseAddressWithProjectKey("Client");
            GetByIdCommand <Category> command               = new GetByIdCommand <Category>(new Guid("2bafc816-4223-4ff0-ac8a-0f08a8f29fd6"));
            GetRequestMessageBuilder  requestMessageBuilder = new GetRequestMessageBuilder(
                this.clientFixture.GetService <IEndpointRetriever>(),
                this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >());
            HttpRequestMessage httpRequestMessage = requestMessageBuilder.GetRequestMessage(command);

            Assert.Equal(HttpMethod.Get, httpRequestMessage.Method);
            Assert.Equal("categories/2bafc816-4223-4ff0-ac8a-0f08a8f29fd6", httpRequestMessage.RequestUri.ToString());
        }
Пример #2
0
        public void InStoreCartByIdRequest()
        {
            var command = new GetByIdCommand <Cart>("2bafc816-4223-4ff0-ac8a-0f08a8f29fd6").InStore("storeKey");

            IHttpApiCommandFactory httpApiCommandFactory = this.clientFixture.GetService <IHttpApiCommandFactory>();
            IHttpApiCommand        httpApiCommand        = httpApiCommandFactory.Create(command);

            HttpRequestMessage httpRequestMessage = httpApiCommand.HttpRequestMessage;

            Assert.Equal(HttpMethod.Get, httpRequestMessage.Method);
            Assert.Equal("in-store/key=storeKey/carts/2bafc816-4223-4ff0-ac8a-0f08a8f29fd6", httpRequestMessage.RequestUri.ToString());

            Assert.Equal(typeof(InStoreHttpApiCommand <Cart>), httpApiCommand.GetType());
        }
Пример #3
0
        public void GetCartWithDiscountExpand()
        {
            var getCommand = new GetByIdCommand <Cart>("986f4791-bc47-4a56-8a3c-f35016be0638");

            getCommand.Expand(
                "lineItems[*].discountedPricePerQuantity[*].discountedPrice.includedDiscounts[*].discount");

            var getRequestMessageBuilder = new GetRequestMessageBuilder(
                this.clientFixture.GetService <IEndpointRetriever>(),
                this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >()
                );
            var httpRequestMessage = getRequestMessageBuilder.GetRequestMessage(getCommand);

            Assert.Equal("carts/986f4791-bc47-4a56-8a3c-f35016be0638?expand=lineItems%5B*%5D.discountedPricePerQuantity%5B*%5D.discountedPrice.includedDiscounts%5B*%5D.discount", httpRequestMessage.RequestUri.ToString());
        }
        public void ProductGetByIdRequestMessageWithPriceCurrency()
        {
            ProductAdditionalParameters productAdditionalParameters = new ProductAdditionalParameters();

            productAdditionalParameters.PriceCurrency = "EUR";
            GetByIdCommand <Product> command = new GetByIdCommand <Product>(new Guid("2bafc816-4223-4ff0-ac8a-0f08a8f29fd6"), productAdditionalParameters);
            // This object cannot be retrieved with GetService method directly.
            // GetRequestMessageBuilder is registered as IRequestMessageBuilder among other request builders.
            GetRequestMessageBuilder requestMessageBuilder = new GetRequestMessageBuilder(
                this.clientFixture.GetService <IEndpointRetriever>(),
                this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >());
            HttpRequestMessage httpRequestMessage = requestMessageBuilder.GetRequestMessage(command);

            Assert.Equal(HttpMethod.Get, httpRequestMessage.Method);
            Assert.Equal("products/2bafc816-4223-4ff0-ac8a-0f08a8f29fd6?priceCurrency=EUR", httpRequestMessage.RequestUri.ToString());
        }
        public async Task GetCustomerInStoreById()
        {
            //Get customer in specific store
            await WithStore(client, async store1 =>
            {
                await WithStore(client, async store2 =>
                {
                    var stores = new List <IReferenceable <Store> >
                    {
                        store1.ToKeyResourceIdentifier(),
                        store2.ToKeyResourceIdentifier()
                    };

                    await WithCustomer(
                        client, customerDraft => DefaultCustomerDraftInStores(customerDraft, stores),
                        async customer =>
                    {
                        Assert.NotNull(customer);
                        Assert.Equal(2, customer.Stores.Count);

                        //using extension method
                        var retrievedCustomer =
                            await client.ExecuteAsync(customer.ToIdResourceIdentifier().GetById()
                                                      .InStore(store1.Key));

                        Assert.NotNull(retrievedCustomer);
                        Assert.Equal(customer.Id, retrievedCustomer.Id);

                        //create InStoreCommand
                        var getCustomerByIdCommand        = new GetByIdCommand <Customer>(customer.Id);
                        var getCustomerInStoreByIdCommand =
                            new InStoreCommand <Customer>(store2.ToKeyResourceIdentifier(), getCustomerByIdCommand);
                        var customerInStore = await client.ExecuteAsync(getCustomerInStoreByIdCommand);
                        Assert.NotNull(customerInStore);
                        Assert.Equal(customer.Id, customerInStore.Id);
                    });
                });
            });
        }
 public async Task <object> Config(GetByIdCommand <Config> command)
 {
     return(await this._mediator.Send <ProjectConfigDto>(command));
 }
 public async Task <object> Get(GetByIdCommand <Solution> command)
 {
     return(await this._mediator.Send <SolutionDto>(command));
 }
Пример #8
0
 public Task <SolutionDto> Handle(GetByIdCommand <Solution> command)
 {
     throw new NotImplementedException();
 }
 public async Task <object> Get(GetByIdCommand <Template> command)
 {
     return(await this._mediator.Send <TemplateDto>(command));
 }
Пример #10
0
 public Task <ProjectDto> Handle(GetByIdCommand <Project> command)
 {
     throw new NotImplementedException();
 }
Пример #11
0
 public Task <TemplateDto> Handle(GetByIdCommand <Template> command)
 {
     throw new NotImplementedException();
 }
Пример #12
0
 public Task <ConfigDto> Handle(GetByIdCommand <Config> command)
 {
     throw new NotImplementedException();
 }