Example #1
0
        public void LoadLegacyNotes_AllNewNotesTest()
        {
            //Generating tests data
            var mockViewBlock = new ExtraWorkspaceViewInfo();

            mockViewBlock.Notes = new[] {
                new ExtraNoteViewInfo()
                {
                    Id   = Guid.NewGuid().ToString(),
                    Text = "Test data text",
                    X    = 1,
                    Y    = 1
                },
                new ExtraNoteViewInfo()
                {
                    Id   = Guid.NewGuid().ToString(),
                    Text = "Test data text",
                    X    = 1,
                    Y    = 1
                }
            };

            //Checks no notes exited before
            Assert.AreEqual(0, this.CurrentDynamoModel.CurrentWorkspace.Notes.Count());

            //Adds and checks if notes where added
            this.CurrentDynamoModel.CurrentWorkspace.UpdateWithExtraWorkspaceViewInfo(mockViewBlock);
            Assert.AreEqual(2, this.CurrentDynamoModel.CurrentWorkspace.Notes.Count());
        }
Example #2
0
        public void UpdatingAWorkspaceWithExtraViewInfo_DoesNotDupliateNotesAndGroups()
        {
            //add a node to the currentWorkspace
            var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));

            this.CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode);
            //put the node in a group
            DynamoSelection.Instance.Selection.Add(addNode);
            //create the group around selected node
            Guid groupid    = Guid.NewGuid();
            var  annotation = this.CurrentDynamoModel.CurrentWorkspace.AddAnnotation("This is a test group", groupid);

            Assert.AreEqual(this.CurrentDynamoModel.CurrentWorkspace.Annotations.Count(), 1);

            //add a note the current workspace
            var newNote = new NoteModel(100, 100, "someText", Guid.NewGuid());

            this.CurrentDynamoModel.CurrentWorkspace.AddNote(newNote, false);

            //now call update with some test data

            var mockViewBlock = new ExtraWorkspaceViewInfo();

            mockViewBlock.Annotations = new[] {
                new ExtraAnnotationViewInfo()
                {
                    Id         = groupid.ToString(),
                    Title      = annotation.AnnotationText,
                    Nodes      = annotation.Nodes.Select(x => x.GUID.ToString()).ToList(),
                    FontSize   = annotation.FontSize,
                    Background = annotation.Background,
                    Left       = annotation.X,
                    Top        = annotation.Y,
                },

                new ExtraAnnotationViewInfo()
                {
                    Id    = newNote.GUID.ToString(),
                    Title = newNote.Text,
                    Nodes = new List <string>(),
                    Left  = annotation.X,
                    Top   = annotation.Y,
                }
            };


            this.CurrentDynamoModel.CurrentWorkspace.UpdateWithExtraWorkspaceViewInfo(mockViewBlock);
            Assert.AreEqual(1, this.CurrentDynamoModel.CurrentWorkspace.Annotations.Count());
            Assert.AreEqual(1, this.CurrentDynamoModel.CurrentWorkspace.Notes.Count());
        }
Example #3
0
        public void LoadLegacyNotes_DuplicatedNoteIdTest()
        {
            Guid toBeDuplicatedId = Guid.NewGuid();

            //Generating tests data
            var mockViewBlock = new ExtraWorkspaceViewInfo();
            var firstNote     = new ExtraNoteViewInfo()
            {
                Id   = toBeDuplicatedId.ToString(),
                Text = "First test note data",
                X    = 1,
                Y    = 1
            };

            mockViewBlock.Notes = new[] { firstNote };

            //Checks no notes exited before
            Assert.AreEqual(0, this.CurrentDynamoModel.CurrentWorkspace.Notes.Count());

            //Adds and checks that the note was added
            this.CurrentDynamoModel.CurrentWorkspace.UpdateWithExtraWorkspaceViewInfo(mockViewBlock);
            Assert.AreEqual(1, this.CurrentDynamoModel.CurrentWorkspace.Notes.Count());

            //Loads a second note with the same id
            mockViewBlock.Notes = new[] {
                new ExtraNoteViewInfo()
                {
                    Id   = toBeDuplicatedId.ToString(),
                    Text = "Second test note data",
                    X    = 1,
                    Y    = 1
                }
            };

            this.CurrentDynamoModel.CurrentWorkspace.UpdateWithExtraWorkspaceViewInfo(mockViewBlock);

            //Checks that there is still only one note
            Assert.AreEqual(1, this.CurrentDynamoModel.CurrentWorkspace.Notes.Count());

            //Verifies that the remaining note is in fact the first one added
            Assert.AreEqual(firstNote.Text, this.CurrentDynamoModel.CurrentWorkspace.Notes.FirstOrDefault().Text);
        }