public void Init() { _treasureCalculator = new TreasureCalculator(); _target = new TreasureController(_treasureCalculator) { Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/api/treasure") } }; var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.EnsureInitialized(); _target.Request.SetConfiguration(config); }
public void Init() { _treasureCalculator = new Mock<ITreasureCalculator>(); _target = new TreasureController(_treasureCalculator.Object) { Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/api/treasure") } }; var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.EnsureInitialized(); _target.Request.SetConfiguration(config); _treasureCalculator .Setup(it => it.GetTreasureCount(It.IsAny<Int32>())) .Returns(expected); }