Example #1
0
        public void GoDown_ComponentInWhichWeWantToGoDownIsComposite_GoDownIntoAComponentAndReturnsTrue()
        {
            //Arrange
            Component newFolder  = SimpleComponentFactory.CreateComponent("Folder", "lowerFolder");
            Component rootFolder = _currentDirectory.GetCurrentComponent();

            rootFolder.Add(newFolder);

            //Act
            bool resultOfGoDown = _currentDirectory.Down("lowerFolder");

            //Assert
            string expectedNameOfCurrentComponent = "lowerFolder";
            string actualNameOfCurrentComponent   = _currentDirectory.GetCurrentComponent().Name;

            Assert.AreEqual(expectedNameOfCurrentComponent, actualNameOfCurrentComponent);
            Assert.True(resultOfGoDown);
        }
Example #2
0
        public void GoDown_ComponentInWhichWeWantToGoDownIsNotComposite_NotGoDownAndReturnsFalse()
        {
            //Arrange
            Component newFile    = SimpleComponentFactory.CreateComponent("File", "lowerFile");
            Component rootFolder = _currentDirectory.GetCurrentComponent();

            rootFolder.Add(newFile);

            //Act
            bool resultOfGoDown = _currentDirectory.Down("lowerFile");

            //Assert
            string expectedNameOfCurrentComponent = "Root";
            string actualNameOfCurrentComponent   = _currentDirectory.GetCurrentComponent().Name;

            Assert.AreEqual(expectedNameOfCurrentComponent, actualNameOfCurrentComponent);
            Assert.False(resultOfGoDown);
        }
Example #3
0
        public void AddPage(string pageName, string link)
        {
            TreeNode       selectedNode = tvBookmark.SelectedNode;
            Component      component    = new Page(_currentComponentId, pageName, link);
            CustomTreeNode treeNode     = new CustomTreeNode(component);

            if (selectedNode == null)
            {
                tvBookmark.Nodes.Add(treeNode);
                _rootComponents[_currentComponentId] = component;
            }
            else
            {
                Component parentComponent = ((CustomTreeNode)selectedNode).Component;
                parentComponent?.Add(component);
                selectedNode.Nodes.Add(treeNode);
            }
            _currentComponentId++;
        }
Example #4
0
        public void AddFolder(string folderName)
        {
            TreeNode       selectedNode = tvBookmark.SelectedNode;
            Component      component    = new Folder(_currentComponentId, folderName);
            CustomTreeNode treeNode     = new CustomTreeNode(component);

            if (selectedNode == null)
            {
                tvBookmark.Nodes.Add(treeNode);
                _rootComponents[_currentComponentId] = component;
            }
            else
            {
                Component parentComponent = ((CustomTreeNode)selectedNode).Component;
                parentComponent?.Add(component);
                selectedNode.Nodes.Add(treeNode);
            }
            _currentComponentId++;
        }
Example #5
0
        public void RiseUp_WeAreNotInTheRoot_RiseUpAndReturnsTrue()
        {
            //Arrange
            Component newFolder  = SimpleComponentFactory.CreateComponent("Folder", "lowerFolder");
            Component rootFolder = _currentDirectory.GetCurrentComponent();

            rootFolder.Add(newFolder);
            _currentDirectory.Down("lowerFolder");

            //Act
            bool resultOfRiseUp = _currentDirectory.Up();

            //Assert
            string expectedNameOfCurrentComponent = "Root";
            string actualNameOfCurrentComponent   = _currentDirectory.GetCurrentComponent().Name;

            Assert.AreEqual(expectedNameOfCurrentComponent, actualNameOfCurrentComponent);
            Assert.True(resultOfRiseUp);
        }
Example #6
0
        public void AddNewComponent_ThereIsNotComponentWithTheSameName_AddingANewComponentAndReturnsTrue()
        {
            //Arrange
            Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder");
            Component newFile   = SimpleComponentFactory.CreateComponent("File", "newFile");

            //Act
            bool resultAfterAddingFolder = _currentFolder.Add(newFolder);
            bool resultAfterAddingFile   = _currentFolder.Add(newFile);

            //Assert
            bool IsTheAddedFolderAppearInTheCurrentFolder = isThereComponent("newFolder");

            bool IsTheAddedFileAppearInTheCurrentFolder = isThereComponent("newFile");


            Assert.True(IsTheAddedFolderAppearInTheCurrentFolder);
            Assert.True(IsTheAddedFileAppearInTheCurrentFolder);

            Assert.True(resultAfterAddingFolder);
            Assert.True(resultAfterAddingFile);
        }
        public void GivenMaximallyUnstableAndConcreteComponent_ReturnsZero()
        {
            var componentA = new Component("componentA");
            var classA     = Class.Abstract("a");

            componentA.Add(classA);

            var componentB = new Component("componentB");
            var classB     = new Class("b");

            classB.AddDependencyOn(classA);
            componentB.Add(classB);

            this.solution.Add(componentA);
            this.solution.Add(componentB);

            AssertMaximallyUnstable(componentB);
            AssertMaximallyConcrete(componentB);

            AssertDistanceFromMainSequence(componentA, 0);
        }
Example #8
0
        private static bool GetSubSubSeriesByID(string idType, int id, Component parent)
        {
            var subseries = _db.Fetch <SubSubSeriesModel>("SELECT id, number, title, description FROM subseries WHERE " + idType + " = " + id);

            if (!subseries.Any())
            {
                return(false);
            }

            var depth    = parent.Depth + 1;
            var position = 1;

            foreach (var sub in subseries)
            {
                var comp = new SubSubSeries("subsubseries", sub);
                comp.Depth    = depth;
                comp.Position = position;
                var sstd            = Utils.GetTitleDate(sub.title, sub.number, "SubSubseries");
                var structuralTitle = "SubSubseries " + sub.number;
                comp.isArchivalObject = sstd.title != structuralTitle;

                sub.SubSubSeriesTitleDate = sstd;
                sub.number = sub.number.Trim();

                var started = GetBoxByID("subseriesID", sub.id, comp);
                if (!started)
                {
                    GetFolderByID("subseriesID", sub.id, comp);
                }
                if (!started)
                {
                    GetSubSeriesByID("subseriesID", sub.id, comp);
                }

                parent.Add(comp);
                position++;
            }

            return(true);
        }
Example #9
0
        private static bool GetFolderByID(string idType, int id, Component parent)
        {
            var folders = _db.Fetch <FolderModel>("SELECT id, letter, title, isOversize, isFolderItem, scope FROM folder WHERE " + idType + " = " + id +
                                                  " ORDER BY CASE WHEN (LEN(letter) = 1) THEN '1' + letter  WHEN letter LIKE '%-%' THEN '1' + SUBSTRING(letter, 0, CHARINDEX('-', letter, 0)) " +
                                                  "WHEN letter LIKE '[a-z].[0-9]' THEN '1' + SUBSTRING(letter, PATINDEX('[a-z]', letter), LEN(letter)) WHEN letter LIKE '%[a-z]' THEN '2' + SUBSTRING(letter, PATINDEX('[a-z]', letter), LEN(letter)) " +
                                                  "WHEN letter LIKE '%os[0-9]' THEN REPLACE(letter, 'os', '300000') " +
                                                  "WHEN letter LIKE '%os[0-9].[0-9]' THEN REPLACE(letter, 'os', '300000') WHEN letter LIKE '%os[0-9][0-9]' THEN REPLACE(letter, 'os', '30000') ELSE '2' + letter END ASC");

            if (!folders.Any())
            {
                return(false);
            }

            var depth    = parent.Depth + 1;
            var position = 1;

            foreach (var folder in folders)
            {
                var comp = new Folder("folder", folder);
                comp.Depth    = depth;
                comp.Position = position;
                var ftd             = Utils.GetTitleDate(folder.title, folder.letter, "Folder");
                var structuralTitle = "Folder " + folder.letter;
                comp.isArchivalObject = ftd.title != structuralTitle;

                folder.FolderTitleDate = ftd;
                folder.letter          = folder.letter.Trim();
                var started = GetSleeveByID("folderID", folder.id, comp);
                if (!started)
                {
                    GetItemByID("folderID", folder.id, comp);
                }
                //if (!started) getItemPartByID("folderID", dv2[j][0].ToString(), c0x);

                parent.Add(comp);
                position++;
            }

            return(true);
        }
Example #10
0
        private static bool GetBoxByID(string idType, int id, Component parent)
        {
            var boxes = _db.Fetch <BoxModel>("SELECT id, number, title, isOversizeFolder, scope, altrender, locationCode FROM box WHERE " + idType + " = " + id + " ORDER BY CASE WHEN number LIKE 'os%[a-z]' " +
                                             "THEN '10000' + SUBSTRING(number, 1, PATINDEX('[a-z]', number)) WHEN number LIKE '%os%' THEN CAST(REPLACE(REPLACE(number, '-', '.'), 'os', '10000') AS FLOAT) " +
                                             "WHEN SUBSTRING(number, 1, 1) = 'm' THEN CAST('9999' AS FLOAT) WHEN number LIKE '%[a-z]' THEN SUBSTRING(number, PATINDEX('[a-z]', number), LEN(number)) " +
                                             "ELSE CAST(REPLACE(REPLACE(number, '-', '.'), 'os', '.5') AS FLOAT) END ASC");

            if (!boxes.Any())
            {
                return(false);
            }

            var depth    = parent.Depth + 1;
            var position = 1;

            foreach (var box in boxes)
            {
                var comp = new Box("box", box);
                comp.Depth    = depth;
                comp.Position = position;
                var btd             = Utils.GetTitleDate(box.title, box.number, "Box");
                var structuralTitle = "Box " + box.number;
                comp.isArchivalObject = btd.title != structuralTitle;

                box.BoxTitleDate = btd;
                box.number       = box.number.Trim();
                var started = GetFolderByID("boxID", box.id, comp);
                if (!started)
                {
                    GetItemByID("boxID", box.id, comp);
                }

                parent.Add(comp);
                position++;
            }

            return(true);
        }
Example #11
0
 public AlertGroupBuilder Alerts(Action <ChildrenExpression <AlertBuilder> > action)
 {
     Children(action).ForEach(b => Component.Add(b));
     return(this);
 }
 public override void BuildTrashBox()
 {
     _product.Add(BuildNewComponent(Enums.ComponentNames.TrashBox), _product.GetRootObjectId());
 }
 public void Add(TimeOrdinalEraPropertyType obj)
 {
     Component.Add(obj);
 }
Example #14
0
 public static T Copy <T>(this Component component, T copy)
     where T : MonoBehaviour, ICopyable <T>
 {
     return(component.Add <T>().Copy(copy));
 }
 public ButtonGroupBuilder Buttons(Action <ChildrenExpression <ButtonBuilder> > action)
 {
     Children(action).ForEach(b => Component.Add(b));
     return(this);
 }
Example #16
0
 public TitleBuilder Add(object value)
 {
     Component.Add(value.ToStringOrDefault());
     return(this);
 }
Example #17
0
 /// <summary>
 /// Adds Component as a child to another GameObject.
 /// Objects position and rotation are set to localPosition and localrotation.
 /// <seealso cref="TransformEx.Add"/>
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="o"></param>
 /// <returns></returns>
 public static GameObject Add(this Component parent, Component o)
 {
     return(parent.Add(o.gameObject));
 }