public void AdditionalDataCheck_CalculationGroupContextWithFailureMechanismParent_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingFailureMechanism();
            var context          = new PipingCalculationGroupContext(failureMechanism.CalculationsGroup,
                                                                     null,
                                                                     Enumerable.Empty <PipingSurfaceLine>(),
                                                                     Enumerable.Empty <PipingStochasticSoilModel>(),
                                                                     failureMechanism,
                                                                     assessmentSection);

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

            // Assert
            Assert.IsTrue(additionalDataCheck);
            mocks.VerifyAll();
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismInAssembly(bool inAssembly)
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism
            {
                InAssembly = inAssembly
            };

            var context = new GrassCoverSlipOffInwardsFailureMechanismContext(failureMechanism, assessmentSection);

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

            // Assert
            Assert.AreEqual(inAssembly, result);
            mocks.VerifyAll();
        }
Esempio n. 4
0
        public void ImplicitOperator_WithAllMethodsSet_InfoFullyConverted()
        {
            // Setup
            var viewInfo = new ViewInfo <int, string, StringView>();

            var       stringView = new StringView();
            const int dataObject = 11;

            const string newDescription = "<text>";
            const string newViewName    = "<view name>";
            const string symbol         = "<symbol>";
            var          fontFamily     = new FontFamily();

            string GetViewName(IView view, int o)
            {
                Assert.AreSame(stringView, view);
                Assert.AreEqual(dataObject, o);
                return(newViewName);
            }

            string GetSymbol() => symbol;
            FontFamily GetFontFamily() => fontFamily;

            bool AdditionalDataCheck(int o)
            {
                Assert.AreEqual(dataObject, o);
                return(true);
            }

            string GetViewData(int o)
            {
                Assert.AreEqual(dataObject, o);
                return(o.ToString());
            }

            var afterCreateCalled = false;

            void AfterCreate(IView view, int o)
            {
                Assert.AreSame(stringView, view);
                Assert.AreEqual(dataObject, o);
                afterCreateCalled = true;
            }

            bool CloseForData(IView view, object o)
            {
                Assert.AreSame(stringView, view);
                Assert.AreEqual(dataObject, o);
                return(true);
            }

            viewInfo.Description         = newDescription;
            viewInfo.GetViewName         = (Func <IView, int, string>)GetViewName;
            viewInfo.GetSymbol           = GetSymbol;
            viewInfo.GetFontFamily       = GetFontFamily;
            viewInfo.AdditionalDataCheck = AdditionalDataCheck;
            viewInfo.GetViewData         = GetViewData;
            viewInfo.AfterCreate         = (Action <IView, int>)AfterCreate;
            viewInfo.CloseForData        = (Func <IView, object, bool>)CloseForData;
            viewInfo.CreateInstance      = o => new StringView
            {
                Text = "A"
            };

            // Precondition
            Assert.IsInstanceOf <ViewInfo <int, string, StringView> >(viewInfo);

            // Call
            ViewInfo info = viewInfo;

            // Assert
            Assert.IsInstanceOf <ViewInfo>(info);
            Assert.AreEqual(typeof(int), info.DataType);
            Assert.AreEqual(typeof(string), info.ViewDataType);
            Assert.AreEqual(typeof(StringView), info.ViewType);
            Assert.AreEqual(newDescription, info.Description);
            Assert.AreEqual(newViewName, info.GetViewName(stringView, dataObject));
            Assert.AreEqual(symbol, info.GetSymbol());
            Assert.AreSame(fontFamily, info.GetFontFamily());
            Assert.IsTrue(viewInfo.AdditionalDataCheck(dataObject));
            Assert.AreEqual(dataObject.ToString(), viewInfo.GetViewData(dataObject));
            Assert.AreEqual("A", viewInfo.CreateInstance(dataObject).Text);

            viewInfo.AfterCreate(stringView, dataObject);
            Assert.IsTrue(afterCreateCalled);
        }