Пример #1
0
        public void GetSlotPageById_ReturnsASlotPageWithSlots()
        {
            SlotPage sp = new SlotPage() { Id = 1, PageName = "Test", Slots = { new Slot(){ Id=1, Headline="test slot"}  } };
            _slotRepository.Stub(r => r.GetSlotPageById(Arg<int>.Is.Anything)).Return(sp);

            var result = _objectUnderTest.GetSlotPageById(1);

            Assert.IsNotNull(result);
        }
Пример #2
0
        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);
        }