public ParcelCost GetCost(Parcel parcel) { ParcelCost parcelCost = null; try { parcelCost = _ruleProcessor.FirstRule.ProcessRule(parcel); } catch (Exception) { // Yell Log Catch Throw } return(parcelCost); }
public void GetParcelCost_returns_correct_object_state(int weight, int height, int width, int depth) { //Given ParcelCost parcelCost = new ParcelCost(20, "mock"); mockParcelManager.Setup(m => m.GetCost(It.IsAny <Parcel>())).Returns(parcelCost); var sut = new ParcelController(mockParcelManager.Object); //When var actual = sut.GetParcelCost(weight, height, width, depth); //Then var result = Assert.IsType <OkObjectResult>(actual); Assert.Equal(200, result.StatusCode); Assert.IsType <ParcelCost>(result.Value); }
public virtual ParcelCost ProcessRule(Parcel parcel) { ParcelCost parcelCost = null; if (this.TryProcessRule(parcel, out decimal cost)) { parcelCost = new ParcelCost(cost, Name); } //Cannot handle it. Passing it to a bigger guy else if (_nextRule != null) { parcelCost = _nextRule.ProcessRule(parcel); } return(parcelCost); }
public Parcel(PackageTypes type = PackageTypes.None, ParcelCost cost = null) { this.Type = type; this.Cost = cost ?? new ParcelCost(-1m); }