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); }
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); }
public static FulfillmentCenterDto ToDto(this FulfillmentCenter center) { var retVal = new FulfillmentCenterDto(); retVal.InjectFrom(center); return(retVal); }
public IHttpActionResult GetNearestFulfillmentCenter([FromBody] GettingNearestCenterRequestDto centerRequest) { FulfillmentCenterDto result = _logisticService.GetNearestFulfillmentCenter(centerRequest); return(Ok(result)); }