public void ChildNodeObjects_WithContext_ReturnsChildrenOfData()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] objects = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(4, objects.Length);

                var assessmentSectionAssemblyGroupsContext = (AssessmentSectionAssemblyGroupsContext)objects[0];
                Assert.AreSame(assessmentSection, assessmentSectionAssemblyGroupsContext.WrappedData);

                var assemblyResultTotalContext = (AssemblyResultTotalContext)objects[1];
                Assert.AreSame(assessmentSection, assemblyResultTotalContext.WrappedData);

                var assemblyResultPerSectionContext = (AssemblyResultPerSectionContext)objects[2];
                Assert.AreSame(assessmentSection, assemblyResultPerSectionContext.WrappedData);

                var assemblyResultPerSectionMapContext = (AssemblyResultPerSectionMapContext)objects[3];
                Assert.AreSame(assessmentSection, assemblyResultPerSectionMapContext.WrappedData);
            }
        }
        public void Constructor_ValidArguments_ExpectedValues()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());

            // Call
            var context = new AssemblyResultsContext(assessmentSection);

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <AssessmentSection> >(context);
            Assert.AreSame(assessmentSection, context.WrappedData);
        }
Пример #3
0
        public void IsEnabled_Always_ReturnsFalse()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                bool isEnabled = info.IsEnabled(context);

                // Assert
                Assert.IsFalse(isEnabled);
            }
        }
Пример #4
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            const string filePath = "test";

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                IFileExporter fileExporter = info.CreateFileExporter(context, filePath);

                // Assert
                Assert.IsInstanceOf <AssemblyExporter>(fileExporter);
            }
        }
        public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            var mocks       = new MockRepository();
            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.Build()).Return(null);
            }

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(context, null, treeViewControl);
                }
            }

            // Assert
            mocks.VerifyAll();
        }