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

            mocks.ReplayAll();

            var failureMechanism        = new SpecificFailureMechanism();
            var failureMechanismContext = new SpecificFailureMechanismContext(new SpecificFailureMechanism(), assessmentSection);

            using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView <SpecificFailureMechanism>(
                       failureMechanism.SectionResults, failureMechanism, assessmentSection,
                       (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual),
                       fm => true,
                       sr => FailureMechanismSectionAssemblyResultWrapperTestFactory.Create()))
            {
                // Call
                bool closeForData = info.CloseForData(view, failureMechanismContext);

                // Assert
                Assert.IsFalse(closeForData);
            }

            mocks.VerifyAll();
        }
Beispiel #2
0
        public void OnNodeRemoved_WithContexts_RemovesFailureMechanismFromCollectionAndNotifiesObservers()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var observer          = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();
            var context          = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            var failureMechanisms = new ObservableList <SpecificFailureMechanism>
            {
                failureMechanism
            };

            failureMechanisms.Attach(observer);
            var parentContext = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

            // Call
            info.OnNodeRemoved(context, parentContext);

            // Assert
            CollectionAssert.IsEmpty(failureMechanisms);
        }
Beispiel #3
0
        public void OnDrop_DataDroppedToDifferentIndex_DroppedDataCorrectlyMovedAndObserversNotified()
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var unmovedFailureMechanism = new SpecificFailureMechanism();
            var movedFailureMechanism   = new SpecificFailureMechanism();
            var failureMechanisms       = new ObservableList <SpecificFailureMechanism>
            {
                unmovedFailureMechanism,
                movedFailureMechanism
            };

            failureMechanisms.Attach(observer);

            var parentData  = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);
            var draggedData = new SpecificFailureMechanismContext(movedFailureMechanism, assessmentSection);

            // Call
            info.OnDrop(draggedData, parentData, parentData, 0, null);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                movedFailureMechanism,
                unmovedFailureMechanism
            }, failureMechanisms);
        }
Beispiel #4
0
        public void Text_Always_ReturnsName()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism        = new SpecificFailureMechanism();
            var failureMechanismContext = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

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

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

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();
            var context          = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

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

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

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();
            var context          = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

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

            // Assert
            Assert.AreEqual(failureMechanism.Name, viewName);
        }
Beispiel #7
0
        public void CloseForData_ViewCorrespondingToRemovedContext_ReturnsTrue()
        {
            // Setup
            var failureMechanism  = new SpecificFailureMechanism();
            var assessmentSection = new AssessmentSectionStub();
            var view = new SpecificFailureMechanismView(failureMechanism, assessmentSection);

            var context = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            bool closeForData = info.CloseForData(view, context);

            // Assert
            Assert.IsTrue(closeForData);
            mocks.VerifyAll();
        }
Beispiel #8
0
        public void AdditionalDataCheck_WithContext_ReturnsFailureMechanismInAssemblyValue(bool inAssembly)
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new SpecificFailureMechanism
            {
                InAssembly = inAssembly
            };
            var context = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

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

            // Assert
            Assert.AreEqual(inAssembly, additionalDataCheck);
        }
Beispiel #9
0
        public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();
            var context          = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).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 sectionsContext = (SpecificFailureMechanismSectionsContext)inputFolder.Contents.ElementAt(0);

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

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

            Assert.AreSame(failureMechanism.InAssemblyInputComments, inAssemblyInputComments);

            var outputFolder = (CategoryTreeFolder)children[1];

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

            Assert.AreEqual(2, outputFolder.Contents.Count());
            var sectionResultContext = (SpecificFailureMechanismSectionResultContext)outputFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism.SectionResults, sectionResultContext.WrappedData);
            Assert.AreSame(failureMechanism, sectionResultContext.FailureMechanism);
            Assert.AreSame(assessmentSection, sectionResultContext.AssessmentSection);

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

            Assert.AreSame(failureMechanism.InAssemblyOutputComments, inAssemblyOutputComments);
        }
Beispiel #10
0
        public void CanDrop_DraggedDataNotPartOfContext_ReturnsFalse()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanisms = new ObservableList <SpecificFailureMechanism>();
            var targetData        = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

            var draggedData = new SpecificFailureMechanismContext(new SpecificFailureMechanism(), assessmentSection);

            // Call
            bool canDrop = info.CanDrop(draggedData, targetData);

            // Assert
            Assert.IsFalse(canDrop);
        }
Beispiel #11
0
        public void CreateInstance_WithContext_ReturnsSpecificFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new SpecificFailureMechanism();
            var context           = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            using (var testForm = new Form())
            {
                // Call
                var view = info.CreateInstance(context) as SpecificFailureMechanismView;

                testForm.Controls.Add(view);
                testForm.Show();

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

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();
            var context          = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <SpecificFailureMechanismProperties>(objectProperties);
            Assert.AreSame(failureMechanism, objectProperties.Data);
            mocks.VerifyAll();
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();

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

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <SpecificFailureMechanism> >(context);
            Assert.IsInstanceOf <IFailureMechanismContext <SpecificFailureMechanism> >(context);
            Assert.AreSame(assessmentSection, context.Parent);
            Assert.AreSame(failureMechanism, context.WrappedData);
            mocks.VerifyAll();
        }
Beispiel #14
0
        public void ContextMenuStrip_FailureMechanismInAssemblyFalse_CallsContextMenuBuilderMethods()
        {
            // Setup
            var failureMechanism = new SpecificFailureMechanism
            {
                InAssembly = false
            };
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var context           = new SpecificFailureMechanismContext(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.AddRenameItem()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddDeleteItem()).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()
            }
        }
Beispiel #15
0
        public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnOnlyFailureMechanismNotInAssemblyComments()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism
            {
                InAssembly = false
            };

            var context = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

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

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

            Assert.AreSame(failureMechanism.NotInAssemblyComments, comment);
        }
Beispiel #16
0
        public void OnNodeRenamed_ChangesNameOfFailureMechanismAndNotifiesObservers()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var observer          = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();

            failureMechanism.Attach(observer);

            var context = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            const string newName = "Updated FailureMechanism name";

            // Call
            info.OnNodeRenamed(context, newName);

            // Assert
            Assert.AreEqual(newName, failureMechanism.Name);
        }