示例#1
0
        public void GetNearestCenter_SingleCenterWasFound()
        {
            // ARRANGE
            GettingNearestCenterRequestDto request = new GettingNearestCenterRequestDto
            {
                PostalCode = "PostalCode_1",
                ProductIds = new List <string> {
                    "1"
                }                                     // OK, exists!
            };

            _commerceServiceMock
            .Setup(x => x.GetAllFulfillmentCenters())
            .Returns(new List <FulfillmentCenter> {
                new FulfillmentCenter {
                    PostalCode = "PostalCode_1", Id = "Ful_Id_1"
                }
            });
            _inventoryRepositoryMock
            .Setup(x => x.Inventories)
            .Returns(new List <Inventory> {
                new Inventory {
                    FulfillmentCenterId = "Ful_Id_1", Sku = "1"
                }
            }.AsQueryable());

            // ACT
            FulfillmentCenterDto center = _LogisticService.GetNearestFulfillmentCenter(request);

            // ASSERT
            Assert.NotNull(center);
            Assert.Equal("Ful_Id_1", center.Id);
        }
示例#2
0
        public void GetNearestCenter_NotFoundAnything_Returns_Null()
        {
            // ARRANGE
            GettingNearestCenterRequestDto request = new GettingNearestCenterRequestDto
            {
                PostalCode = "PostalCode_1",
                ProductIds = new List <string> {
                    "2"
                }                                     // FAIL, only product with Id = "1" exists!
            };

            _commerceServiceMock
            .Setup(x => x.GetAllFulfillmentCenters())
            .Returns(new List <FulfillmentCenter> {
                new FulfillmentCenter {
                    PostalCode = "PostalCode_1", Id = "Ful_Id_1"
                }
            });
            _inventoryRepositoryMock
            .Setup(x => x.Inventories)
            .Returns(new List <Inventory> {
                new Inventory {
                    FulfillmentCenterId = "Ful_Id_1", Sku = "1"
                }
            }.AsQueryable());

            // ACT
            FulfillmentCenterDto center = _LogisticService.GetNearestFulfillmentCenter(request);

            // ASSERT
            Assert.Null(center);
        }
示例#3
0
        public static FulfillmentCenterDto ToDto(this FulfillmentCenter center)
        {
            var retVal = new FulfillmentCenterDto();

            retVal.InjectFrom(center);
            return(retVal);
        }
示例#4
0
        public IHttpActionResult GetNearestFulfillmentCenter([FromBody] GettingNearestCenterRequestDto centerRequest)
        {
            FulfillmentCenterDto result = _logisticService.GetNearestFulfillmentCenter(centerRequest);

            return(Ok(result));
        }