public void GetSlotPageById_WithSlotHavingAnImage_ReturnedSlotHasImageUrl() { //Arrange HttpConfiguration config = new HttpConfiguration(); var route = config.Routes.MapHttpRoute ( name: "GetMediaContentById", routeTemplate: "mediacontent/{id}" ); var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "id", "1" } }); HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, "http://localhost:80/slotpage/1"); req.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, config); req.Properties.Add(HttpPropertyKeys.HttpRouteDataKey, routeData); _urlHelper = new TWG.EASDataService.Api.Helpers.UrlHelper(new System.Web.Http.Routing.UrlHelper(req)); _objectUnderTest = new SlotController(_slotService, _urlHelper); _objectUnderTest.Request = req; var slot = new Slot() { Id = 1, Headline = "test slot", Image = new Image() { Name = "dummy image", Id = 1000, Extension = "jpg" } }; SlotPage sp = new SlotPage() { Id = 1, PageName = "Test", Slots = { slot } }; _slotRepository.Stub(r => r.GetSlotPageById(Arg<int>.Is.Anything)).Return(sp); //Act var result = _objectUnderTest.GetSlotPageById(1); //Assert Image img = result.Slots.FirstOrDefault().Image; Assert.AreNotEqual(string.Empty,img.Url); }
public void Setup() { _slotRepository = MockRepository.GenerateStub<ISlotRepository>(); _slotService = new SlotService(_slotRepository); _urlHelper = MockRepository.GenerateStub<IUrlHelper>(); _objectUnderTest = new SlotController(_slotService, _urlHelper); _objectUnderTest.Request = new HttpRequestMessage(); _objectUnderTest.Request.SetConfiguration(new HttpConfiguration()); }