public void Will_Return_ServiceUnavailable_For_Generic_Exception() { IPercentileService percentileService = Substitute.For <IPercentileService>(); percentileService.CalculatePercentile(.995, testValues).ThrowsForAnyArgs <Exception>(); PercentileController controller = new PercentileController(percentileService, dataAccessService); var res = controller.Get(0.995); Assert.AreEqual("Service Unavailable", ((ObjectResult)res.Result).Value); }
public void Will_Return_Percentile_For_Successful_Call() { IPercentileService percentileService = Substitute.For <IPercentileService>(); percentileService.CalculatePercentile(.995, testValues).Returns <double>(123); PercentileController controller = new PercentileController(percentileService, dataAccessService); var percentile = controller.Get(0.995); Assert.AreEqual(123, percentile.Value); }
public void Will_Return_BadRequest_For_ArgumentOutOfRangeException() { IPercentileService percentileService = Substitute.For <IPercentileService>(); percentileService.CalculatePercentile(.995, testValues).ThrowsForAnyArgs <ArgumentOutOfRangeException>(); PercentileController controller = new PercentileController(percentileService, dataAccessService); var res = controller.Get(0.995); Assert.AreEqual("Bad Request", ((ObjectResult)res.Result).Value); }
public IndexModel(IPercentileService percentileService) { this._percentileService = percentileService; }
public PercentileController(IPercentileService percentileService, IPercentileDataAccess percentileDataAccess) { _percentileService = percentileService; _percentileDataAccess = percentileDataAccess; }