private Vocabulary GetVocabulary()
        {
            var vocabulary = new Vocabulary();
            var scopeType  = IsSuperUser ? ScopeTypeController.GetScopeTypes().Where(s => s.ScopeType == "Application").SingleOrDefault() : ScopeTypeController.GetScopeTypes().Where(s => s.ScopeType == "Portal").SingleOrDefault();

            if (scopeType != null)
            {
                vocabulary.ScopeTypeId = scopeType.ScopeTypeId;
            }
            vocabulary.Type = VocabularyType.Simple;

            return(vocabulary);
        }
Пример #2
0
        public void ScopeTypeController_GetScopeTypes_Returns_List_Of_ScopeTypes()
        {
            // Arrange
            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetScopeTypes()).Returns(MockHelper.CreateValidScopeTypesReader(Constants.SCOPETYPE_ValidScopeTypeCount));
            var scopeTypeController = new ScopeTypeController(mockDataService.Object);

            // Act
            var scopeTypes = scopeTypeController.GetScopeTypes();

            // Assert
            Assert.AreEqual(Constants.SCOPETYPE_ValidScopeTypeCount, scopeTypes.Count());
        }
Пример #3
0
        public void ScopeTypeController_GetScopeTypes_Calls_DataService()
        {
            // Arrange
            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetScopeTypes()).Returns(MockHelper.CreateValidScopeTypesReader(Constants.SCOPETYPE_ValidScopeTypeCount));
            var scopeTypeController = new ScopeTypeController(mockDataService.Object);

            // Act
            IQueryable <ScopeType> scopeTypes = scopeTypeController.GetScopeTypes();

            // Assert
            mockDataService.Verify(ds => ds.GetScopeTypes());
        }
Пример #4
0
        public void ScopeTypeController_GetScopeTypes_Returns_Empty_List_Of_ScopeTypes_If_No_ScopeTypes()
        {
            // Arrange
            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetScopeTypes()).Returns(MockHelper.CreateEmptyScopeTypeReader());
            var scopeTypeController = new ScopeTypeController(mockDataService.Object);

            // Act
            var scopeTypes = scopeTypeController.GetScopeTypes();

            // Assert
            Assert.IsNotNull(scopeTypes);
            Assert.AreEqual(0, scopeTypes.Count());
        }
Пример #5
0
        public void BindVocabulary(Vocabulary vocabulary, bool editEnabled, bool showScope)
        {
            if (IsPostBack)
            {
                vocabulary.Name        = nameTextBox.Text;
                vocabulary.Description = descriptionTextBox.Text;

                var       scopeTypeController = new ScopeTypeController();
                ScopeType scopeType;
                scopeType = scopeTypeController.GetScopeTypes().Where(s => s.ScopeType == scopeList.SelectedValue).SingleOrDefault();
                vocabulary.ScopeTypeId = scopeType.ScopeTypeId;

                vocabulary.Type = typeList.SelectedValue == "Simple" ? VocabularyType.Simple : VocabularyType.Hierarchy;
            }
            else
            {
                nameTextBox.Text        = vocabulary.Name;
                nameLabel.Text          = vocabulary.Name;
                descriptionTextBox.Text = vocabulary.Description;
                typeList.Items.FindByValue(vocabulary.Type.ToString()).Selected = true;
                if (vocabulary.ScopeType != null)
                {
                    scopeLabel.Text = vocabulary.ScopeType.ScopeType;
                    scopeList.Items.FindByValue(vocabulary.ScopeType.ScopeType).Selected = true;
                }
                typeLabel.Text = vocabulary.Type.ToString();
            }

            nameTextBox.Visible        = IsAddMode;
            nameLabel.Visible          = !IsAddMode;
            descriptionTextBox.Enabled = editEnabled;
            scopeList.Visible          = (IsAddMode && showScope);
            scopeLabel.Visible         = !(IsAddMode && showScope);
            typeList.Visible           = IsAddMode;
            typeLabel.Visible          = !IsAddMode;
        }