Пример #1
0
        public void CanViewIndex()
        {
            //Act
            var result = _translationController.Index() as ViewResult;


            //Assert
            Assert.NotNull(result);

            var model = result.Model;

            Assert.IsInstanceOf <Translation>(model);

            Assert.IsInstanceOf <ViewResult>(result);
            Assert.IsInstanceOf <List <Translation> >(((ViewResult)result).Model);
            Assert.AreEqual(2, ((IEnumerable <Translation>)model).Count());
        }
Пример #2
0
        // here we make a dummy translation with 53
        // segments max 50 segments are displayed at
        // a time on the site( 50 on every page)
        // the second page should include 3 segments
        public void TestTranslationIndex()
        {
            //Arrange

            var translation = new Translation
            {
                ID         = 1,
                MediaID    = 2,
                LanguageID = 3,
                Media      = new Media {
                    Title = "Dummy"
                },
                Language = new Language {
                    Name = "Dummy2"
                },
                TranslationSegments = new List <TranslationSegment>()
            };

            for (int i = 1; i < 54; i++)
            {
                var segment = new TranslationSegment
                {
                    SegmentID   = i,
                    Translation = translation
                };
                translation.TranslationSegments.Add(segment);
            }
            var mockUnitOfWork = new MockUnitOfWork();

            mockUnitOfWork.TranslationRepository.Insert(translation);
            var controller = new TranslationController(mockUnitOfWork);

            //Act
            var result = controller.Index(1, 2);

            // Assert
            var viewResult = (ViewResult)result;
            PagedList <TranslationSegment> model = viewResult.Model as PagedList <TranslationSegment>;

            Assert.IsTrue(model.Count == 3);
        }