public void TestGettingTranslationById()
        {
            // Arrange:
            List<Translation> translations = new List<Translation>();

            for (int i = 0; i < 15; i++)
            {
                translations.Add(new Translation
                {
                    ID = i,
                    vID = i % 3,
                    translationName = "Hackers",
                    translationCategory = "Hasar",
                    translationDescription = "Lorem ipsum",
                    translationLanguage = "English" + i.ToString(),
                    translationText = "Lorem ipsum",
                    averageVotes = Convert.ToDouble(i),
                    translationTime = DateTime.Now.AddDays(i)
                });
            }
            var mockRepo = new Mocks.MockTranslationRepository(translations);
            var controller = new MockVideoController(mockRepo);

            // Act:
            // Get translation with id == 7.
            var result = controller.GetTranslationById(7);

            // Assert:
            var viewResult = (ViewResult)result;
            List<Translation> model = (viewResult.Model as IEnumerable<Translation>).ToList();

            Assert.IsTrue(model.Count == 1);
            Assert.IsTrue(model[0].ID == 7);
        }
        public void TestIfTranslationsAreOrderedByLanguageDescending()
        {
            // Arrange:
            List<Translation> translations = new List<Translation>();

            for (int i = 0; i < 30; i++)
            {
                translations.Add(new Translation
                {
                    ID = i,
                    vID = i % 3,
                    translationName = "Hackers",
                    translationCategory = "Hasar",
                    translationDescription = "Lorem ipsum",
                    translationLanguage = "English" + i.ToString(),
                    translationText = "Lorem ipsum",
                    translationTime = DateTime.Now.AddDays(i)
                });
            }
            var mockRepo = new Mocks.MockTranslationRepository(translations);
            var controller = new MockVideoController(mockRepo);

            // Act:
            // Get translations ordered by language descending.
            var result = controller.GetTranslationByVideoId(1, null, "lang_desc");

            // Assert:
            var viewResult = (ViewResult)result;
            List<Translation> model = (viewResult.Model as IEnumerable<Translation>).ToList();

            for (int i = 0; i < model.Count - 1; i++)
            {
                int compare = String.Compare(model[i].translationLanguage, model[i + 1].translationLanguage);
                Assert.IsTrue(compare >= 0);
            }
        }
        public void TryToGetMoreThan10Translations()
        {
            // Arrange:
            List<Translation> translations = new List<Translation>();

            for(int i = 0; i < 13; i++)
            {
                translations.Add(new Translation
                {
                    ID = i,
                    vID = i % 3,
                    translationName = "Hackers",
                    translationCategory = "Hasar",
                    translationDescription = "Lorem ipsum",
                    translationLanguage = "English",
                    translationText = "Lorem ipsum",
                    translationTime = DateTime.Now.AddDays(i)
                });
            }

            var mockRepo = new Mocks.MockTranslationRepository(translations);
            var controller = new MockVideoController(mockRepo);

            // Act:
            // Get the translations with vId == 2.
            var result = controller.GetTranslationByVideoId(2, null, "");

            // Assert:
            var viewResult = (ViewResult)result;
            List<Translation> model = (viewResult.Model as IEnumerable<Translation>).ToList();

            foreach(var item in model)
            {
                Assert.IsTrue(item.vID == 2);
            }

            Assert.IsTrue(model.Count == 4);
        }
        public void TestIfTranslationsAreOrderedByDownloadCountAscending()
        {
            // Arrange:
            List<Translation> translations = new List<Translation>();

            for (int i = 0; i < 30; i++)
            {
                translations.Add(new Translation
                {
                    ID = i,
                    vID = i % 3,
                    translationName = "Hackers",
                    translationCategory = "Hasar",
                    translationDescription = "Lorem ipsum",
                    translationLanguage = "English" + i.ToString(),
                    translationText = "Lorem ipsum",
                    downloadCount = i,
                    translationTime = DateTime.Now.AddDays(i)
                });
            }
            var mockRepo = new Mocks.MockTranslationRepository(translations);
            var controller = new MockVideoController(mockRepo);

            // Act:
            // Get translations ordered by count ascending.
            var resultAscending = controller.GetTranslationByVideoId(1, null, "Count");

            // Assert:
            var viewResultAscending = (ViewResult)resultAscending;
            List<Translation> modelAscending = (viewResultAscending.Model as IEnumerable<Translation>).ToList();

            for (int i = 0; i < modelAscending.Count - 1; i++)
            {
                Assert.IsTrue(modelAscending[i].downloadCount <= modelAscending[i + 1].downloadCount);
            }
        }