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

            mocks.ReplayAll();

            ClosingStructure closingStructure1 = new TestClosingStructure("structure1");
            ClosingStructure closingStructure2 = new TestClosingStructure("structure2");
            var failureMechanism = new ClosingStructuresFailureMechanism();

            failureMechanism.ClosingStructures.AddRange(new[]
            {
                closingStructure1,
                closingStructure2
            }, "some path");

            var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

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

            // Assert
            Assert.AreEqual(2, children.Length);
            Assert.AreSame(closingStructure1, children.ElementAt(0));
            Assert.AreSame(closingStructure2, children.ElementAt(1));
            mocks.VerifyAll();
        }
Beispiel #2
0
        public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var mainWindow        = mocks.Stub <IMainWindow>();
            var gui = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

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

                var failureMechanism = new ClosingStructuresFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput>());

                var structures = new StructureCollection <ClosingStructure>();
                var context    = new ClosingStructuresContext(structures, failureMechanism, assessmentSection);

                ImportInfo importInfo = GetImportInfo(plugin);

                // Call
                bool updatesVerified = importInfo.VerifyUpdates(context);

                // Assert
                Assert.IsTrue(updatesVerified);
                mocks.VerifyAll();
            }
        }
Beispiel #3
0
        public void ForeColor_CollectionHasElementsEmpty_ReturnControlText()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            failureMechanism.ClosingStructures.AddRange(new[]
            {
                new TestClosingStructure()
            }, "some path");

            // Precondition
            CollectionAssert.IsNotEmpty(failureMechanism.ClosingStructures);

            var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            // Call
            Color color = info.ForeColor(closingStructuresContext);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
            mocks.VerifyAll();
        }
Beispiel #4
0
        public void IsEnabled_ReferenceLineWithoutGeometry_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();
            var context          = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            using (var plugin = new ClosingStructuresPlugin())
            {
                ImportInfo importInfo = GetImportInfo(plugin);

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

                // Assert
                Assert.IsFalse(isEnabled);
            }

            mocks.VerifyAll();
        }
Beispiel #5
0
        public void CreateFileImporter_Always_ReturnFileImporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();
            var importTarget     = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            using (var plugin = new ClosingStructuresPlugin())
            {
                ImportInfo importInfo = GetImportInfo(plugin);

                // Call
                IFileImporter importer = importInfo.CreateFileImporter(importTarget, "test");

                // Assert
                Assert.IsInstanceOf <ClosingStructuresImporter>(importer);
            }

            mocks.VerifyAll();
        }
Beispiel #6
0
 private static IFileImporter CreateClosingStructuresImporter(ClosingStructuresContext context,
                                                              string filePath,
                                                              IImporterMessageProvider importerMessageProvider,
                                                              IStructureUpdateStrategy <ClosingStructure> structureUpdateStrategy)
 {
     return(new ClosingStructuresImporter(context.WrappedData,
                                          context.AssessmentSection.ReferenceLine,
                                          filePath,
                                          importerMessageProvider,
                                          structureUpdateStrategy));
 }
Beispiel #7
0
        public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var mainWindow        = mocks.Stub <IMainWindow>();
            var gui = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

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

                var failureMechanism = new ClosingStructuresFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput>
                {
                    Output = new TestStructuresOutput()
                });

                var structures = new StructureCollection <ClosingStructure>();
                var context    = new ClosingStructuresContext(structures, failureMechanism, assessmentSection);

                ImportInfo importInfo = GetImportInfo(plugin);

                string textBoxMessage = null;
                DialogBoxHandler = (name, wnd) =>
                {
                    var helper = new MessageBoxTester(wnd);
                    textBoxMessage = helper.Text;

                    if (isActionConfirmed)
                    {
                        helper.ClickOk();
                    }
                    else
                    {
                        helper.ClickCancel();
                    }
                };

                // Call
                bool updatesVerified = importInfo.VerifyUpdates(context);

                // Assert
                string expectedInquiryMessage = "Als u kunstwerken importeert, dan worden alle rekenresultaten van dit faalmechanisme verwijderd." +
                                                $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
                Assert.AreEqual(expectedInquiryMessage, textBoxMessage);
                Assert.AreEqual(isActionConfirmed, updatesVerified);
                mocks.VerifyAll();
            }
        }
Beispiel #8
0
        public void Image_Always_ReturnExpectedImage()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            // Call
            Image image = info.Image(closingStructuresContext);

            // Assert
            TestHelper.AssertImagesAreEqual(Resources.GeneralFolderIcon, image);
            mocks.VerifyAll();
        }
        public void ParameteredConstructor_ExpectedValues()
        {
            // Setup
            var mocks = new MockRepository();
            var assessmentSection = mocks.Stub<IAssessmentSection>();
            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            // Call
            var context = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf<ObservableWrappedObjectContextBase<StructureCollection<ClosingStructure>>>(context);
            Assert.AreSame(failureMechanism, failureMechanism);
            Assert.AreSame(failureMechanism.ClosingStructures, context.WrappedData);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocks.VerifyAll();
        }
Beispiel #10
0
        public void IsEnabled_SourcePathNull_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();
            var structures       = new StructureCollection <ClosingStructure>();

            var context = new ClosingStructuresContext(structures, failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsFalse(isEnabled);
            mocks.VerifyAll();
        }
Beispiel #11
0
        public void Text_Always_ReturnExpectedText()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

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

            // Assert
            const string expectedText = "Kunstwerken";

            Assert.AreEqual(expectedText, text);
            mocks.VerifyAll();
        }
Beispiel #12
0
        public void CreateFileImporter_ValidInput_ReturnFileImporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();
            var structures       = new StructureCollection <ClosingStructure>();

            var importTarget = new ClosingStructuresContext(structures, failureMechanism, assessmentSection);

            // Call
            IFileImporter importer = updateInfo.CreateFileImporter(importTarget, "This is valid");

            // Assert
            Assert.IsInstanceOf <ClosingStructuresImporter>(importer);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_NewPropertiesWithContextAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            var collection = new StructureCollection <ClosingStructure>();
            var context    = new ClosingStructuresContext(collection, failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <StructureCollectionProperties <ClosingStructure> >(objectProperties);
            Assert.AreSame(collection, objectProperties.Data);

            mocks.VerifyAll();
        }
Beispiel #14
0
        public void ForeColor_CollectionIsEmpty_ReturnGrayText()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            // Precondition
            CollectionAssert.IsEmpty(failureMechanism.ClosingStructures);

            var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            // Call
            Color color = info.ForeColor(closingStructuresContext);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
            mocks.VerifyAll();
        }
Beispiel #15
0
        public void CurrentPath_StructureCollectionHasPathSet_ReturnsExpectedPath()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            const string expectedFilePath = "some/path";
            var          structures       = new StructureCollection <ClosingStructure>();

            structures.AddRange(Enumerable.Empty <ClosingStructure>(), expectedFilePath);

            var failureMechanism = new ClosingStructuresFailureMechanism();
            var context          = new ClosingStructuresContext(structures, failureMechanism, assessmentSection);

            // Call
            string currentPath = updateInfo.CurrentPath(context);

            // Assert
            Assert.AreEqual(expectedFilePath, currentPath);
            mocks.VerifyAll();
        }
Beispiel #16
0
        public void IsEnabled_SourcePathSet_ReturnTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new ClosingStructuresFailureMechanism();

            failureMechanism.ClosingStructures.AddRange(Enumerable.Empty <ClosingStructure>(), "some path");

            var context = new ClosingStructuresContext(failureMechanism.ClosingStructures,
                                                       failureMechanism,
                                                       assessmentSection);

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

            // Assert
            Assert.IsTrue(isEnabled);
            mocks.VerifyAll();
        }