示例#1
0
        public void VocabularyController_UpdateVocabulary_Throws_On_Null_Vocabulary()
        {
            //Arrange
            var mockDataService      = new Mock <IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws <ArgumentNullException>(() => vocabularyController.UpdateVocabulary(null));
        }
        public void VocabularyController_UpdateVocabulary_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.UpdateVocabulary(vocabulary));
        }
        public void VocabularyController_UpdateVocabulary_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<ArgumentOutOfRangeException>(() => vocabularyController.UpdateVocabulary(vocabulary));
        }
示例#4
0
        public void UpdateVocabulary(Vocabulary vocabulary)
        {
            var result = _validator.ValidateObject(vocabulary);

            if (result.IsValid)
            {
                _vocabularyController.UpdateVocabulary(vocabulary);
            }
            else
            {
                throw new VocabularyValidationException();
            }
        }
        public void VocabularyController__UpdateVocabulary_Clears_Vocabulary_Cache_On_Valid_Vocabulary()
        {
            // Arrange
            var mockDataService = new Mock<IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();
            vocabulary.VocabularyId = Constants.VOCABULARY_UpdateVocabularyId;

            // Act
            vocabularyController.UpdateVocabulary(vocabulary);

            // Assert
            this.mockCache.Verify(cache => cache.Remove(Constants.VOCABULARY_CacheKey));
        }
        public void VocabularyController_UpdateVocabulary_Calls_DataService_On_Valid_Arguments()
        {
            // Arrange
            var mockDataService = new Mock<IDataService>();
            var vocabularyController = new VocabularyController(mockDataService.Object);

            Vocabulary vocabulary = ContentTestHelper.CreateValidVocabulary();
            vocabulary.VocabularyId = Constants.VOCABULARY_UpdateVocabularyId;

            // Act
            vocabularyController.UpdateVocabulary(vocabulary);

            // Assert
            mockDataService.Verify(ds => ds.UpdateVocabulary(vocabulary, It.IsAny<int>()));
        }
        public void SaveVocabulary(object sender, EventArgs e)
        {
            View.BindVocabulary(View.Model.Vocabulary, IsEditEnabled, IsDeleteEnabled, IsSuperUser);

            var result = Validator.ValidateObject(View.Model.Vocabulary);

            if (result.IsValid)
            {
                VocabularyController.UpdateVocabulary(View.Model.Vocabulary);
                Response.Redirect(Globals.NavigateURL(TabId));
            }
            else
            {
                ShowMessage("VocabularyValidationError", ModuleMessage.ModuleMessageType.RedError);
            }
        }
示例#8
0
        public void UpdateVocabulary(Vocabulary vocabulary)
        {
            if (vocabulary.ScopeType.ScopeType == Constants.VocabularyScopeTypeWebsite)
            {
                vocabulary.ScopeId = PortalSettings.Current.PortalId;
            }
            var result = _validator.ValidateObject(vocabulary);

            if (result.IsValid)
            {
                _vocabularyController.UpdateVocabulary(vocabulary);
            }
            else
            {
                throw new VocabularyValidationException();
            }
        }