public void VocabularyController_AddVocabulary_Throws_On_Null_Vocabulary()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws<ArgumentNullException>(() => vocabularyController.AddVocabulary(null));
        }
        public void VocabularyController_AddVocabulary_Calls_DataService_On_Valid_Arguments()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            VocabularyController vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();

            //Act
            int vocabularyId = vocabularyController.AddVocabulary(vocabulary);

            //Assert
            mockDataService.Verify(ds => ds.AddVocabulary(vocabulary, It.IsAny<int>()));
        }
        public void VocabularyController_AddVocabulary_Throws_On_Negative_ScopeTypeID()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();
            vocabulary.ScopeTypeId = Null.NullInteger;

            //Act, Arrange
            Assert.Throws<ArgumentOutOfRangeException>(() => vocabularyController.AddVocabulary(vocabulary));
        }
        public void VocabularyController_AddVocabulary_Throws_On_Invalid_Name()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();
            vocabulary.Name = Constants.VOCABULARY_InValidName;

            //Act, Arrange
            Assert.Throws<ArgumentException>(() => vocabularyController.AddVocabulary(vocabulary));
        }
        public void VocabularyController_AddVocabulary_Clears_Vocabulary_Cache_On_Valid_Vocabulary()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();

            //Act
            vocabularyController.AddVocabulary(vocabulary);

            //Assert
            mockCache.Verify(cache => cache.Remove(Constants.VOCABULARY_CacheKey));
        }
        public void VocabularyController_AddVocabulary_Sets_ValidId_On_Valid_Vocabulary()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.AddVocabulary(It.IsAny<Vocabulary>(), It.IsAny<int>())).Returns(Constants.VOCABULARY_AddVocabularyId);
            var vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();

            //Act
            vocabularyController.AddVocabulary(vocabulary);

            //Assert
            Assert.AreEqual(Constants.VOCABULARY_AddVocabularyId, vocabulary.VocabularyId);
        }
        public void VocabularyController_AddVocabulary_Throws_On_Null_Vocabulary()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            VocabularyController vocabularyController = new VocabularyController(mockDataService.Object);

            //Act, Arrange
            AutoTester.ArgumentNull<Vocabulary>(vocabulary => vocabularyController.AddVocabulary(vocabulary));
        }