Exemple #1
0
        public void Text_Always_ReturnsName()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism        = new PipingStructureFailureMechanism();
            var failureMechanismContext = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            string text = info.Text(failureMechanismContext);

            // Assert
            Assert.AreEqual(failureMechanism.Name, text);
        }
Exemple #2
0
        public void ForeColor_Always_ReturnsControlText()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingStructureFailureMechanism();
            var context          = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            Color textColor = info.ForeColor(context);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), textColor);
        }
        public void GetViewName_WithFailureMechanismContext_ReturnsNameOfFailureMechanism()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism        = new PipingStructureFailureMechanism();
            var failureMechanismContext = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            string viewName = info.GetViewName(null, failureMechanismContext);

            // Assert
            Assert.AreEqual(failureMechanism.Name, viewName);
        }
Exemple #4
0
        public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            var failureMechanism        = new PipingStructureFailureMechanism();
            var failureMechanismContext = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);
            var inputFolder = (CategoryTreeFolder)children[0];

            Assert.AreEqual(2, inputFolder.Contents.Count());
            Assert.AreEqual("Invoer", inputFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Input, inputFolder.Category);

            var failureMechanismSectionsContext = (PipingStructureFailureMechanismSectionsContext)inputFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData);
            Assert.AreSame(assessmentSection, failureMechanismSectionsContext.AssessmentSection);

            var inAssemblyInputComments = (Comment)inputFolder.Contents.ElementAt(1);

            Assert.AreSame(failureMechanism.InAssemblyInputComments, inAssemblyInputComments);

            var outputFolder = (CategoryTreeFolder)children[1];

            Assert.AreEqual(2, outputFolder.Contents.Count());
            Assert.AreEqual("Oordeel", outputFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Output, outputFolder.Category);

            var failureMechanismResultsContext = (PipingStructureFailureMechanismSectionResultContext)
                                                 outputFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
            Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData);

            var inAssemblyOutputComments = (Comment)outputFolder.Contents.ElementAt(1);

            Assert.AreSame(failureMechanism.InAssemblyOutputComments, inAssemblyOutputComments);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingStructureFailureMechanism();

            // Call
            var context = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <FailureMechanismContext <PipingStructureFailureMechanism> >(context);
            Assert.AreSame(assessmentSection, context.Parent);
            Assert.AreSame(failureMechanism, context.WrappedData);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingStructureFailureMechanism();
            var context          = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <PipingStructureFailureMechanismProperties>(objectProperties);
            Assert.AreSame(failureMechanism, objectProperties.Data);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithData_ReturnFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new PipingStructureFailureMechanism();

            var context = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <StandAloneFailureMechanismView <PipingStructureFailureMechanism,
                                                                 NonAdoptableFailureMechanismSectionResult> >(view);

            var failureMechanismView = (StandAloneFailureMechanismView <PipingStructureFailureMechanism,
                                                                        NonAdoptableFailureMechanismSectionResult>)view;

            Assert.AreSame(failureMechanism, failureMechanismView.FailureMechanism);
            Assert.AreSame(assessmentSection, failureMechanismView.AssessmentSection);
        }
        public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismInAssembly(bool inAssembly)
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingStructureFailureMechanism
            {
                InAssembly = inAssembly
            };

            var context = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            bool result = info.AdditionalDataCheck(context);

            // Assert
            Assert.AreEqual(inAssembly, result);
            mocks.VerifyAll();
        }
Exemple #9
0
        public void ChildNodeObjects_FailureMechanismInAssemblyFalse_ReturnOnlyFailureMechanismNotInAssemblyComments()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingStructureFailureMechanism
            {
                InAssembly = false
            };

            var failureMechanismContext = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();

            // Assert
            Assert.AreEqual(1, children.Length);
            var comment = (Comment)children[0];

            Assert.AreSame(failureMechanism.NotInAssemblyComments, comment);
        }
Exemple #10
0
        public void ContextMenuStrip_FailureMechanismInAssemblyFalse_CallsContextMenuBuilderMethods()
        {
            // Setup
            var failureMechanism = new PipingStructureFailureMechanism
            {
                InAssembly = false
            };
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var context           = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            using (var treeView = new TreeViewControl())
            {
                var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();
                using (mocks.Ordered())
                {
                    menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().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.AddSeparator()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.Build()).Return(null);
                }

                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                plugin.Gui = gui;

                // Call
                info.ContextMenuStrip(context, assessmentSection, treeView);

                // Assert
                // Assert expectancies are called in TearDown()
            }
        }