Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public IndexModel(IPercentileService percentileService)
 {
     this._percentileService = percentileService;
 }
Beispiel #5
0
 public PercentileController(IPercentileService percentileService, IPercentileDataAccess percentileDataAccess)
 {
     _percentileService    = percentileService;
     _percentileDataAccess = percentileDataAccess;
 }