Exemplo n.º 1
0
        public void CreateInstance_WithContext_SetsFailureMechanismContributionAsData()
        {
            // Setup
            var  mocks             = new MockRepository();
            var  assessmentSection = mocks.Stub <IAssessmentSection>();
            var  viewCommands      = mocks.Stub <IViewCommands>();
            IGui gui = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.ViewCommands).Return(viewCommands);
            mocks.ReplayAll();

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();
                var context = new NormContext(failureMechanismContribution, assessmentSection);

                PropertyInfo info = GetInfo(plugin);

                // Call
                IObjectProperties objectProperties = info.CreateInstance(context);

                // Assert
                Assert.IsInstanceOf <NormProperties>(objectProperties);
                Assert.AreSame(failureMechanismContribution, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
Exemplo n.º 2
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            FailureMechanismContribution contribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();

            // Call
            var context = new NormContext(contribution, assessmentSection);

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <FailureMechanismContribution> >(context);
            Assert.AreSame(contribution, context.WrappedData);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocks.VerifyAll();
        }
        public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var context           = new NormContext(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution(),
                                                    assessmentSection);

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

            using (mocks.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddPropertiesItem()).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();
        }