Beispiel #1
0
        public void Test_AssociationEditDlgController()
        {
            var view = Substitute.For <IAssociationEditDlg>();

            Assert.IsNull(view.Association);
            Assert.IsNotNull(view.Person);
            Assert.IsNotNull(view.Relation);

            var baseContext = Substitute.For <IBaseContext>();

            baseContext.Tree.Returns(new GDMTree());
            var baseWin = Substitute.For <IBaseWindow>();

            baseWin.Context.Returns(baseContext);
            var tree        = baseContext.Tree;
            var association = new GDMAssociation(); // for xref pointers to work

            var controller = new AssociationEditDlgController(view);

            Assert.IsNotNull(controller);

            controller.Init(baseWin);
            Assert.AreEqual(baseWin, controller.Base);

            controller.Association = association;
            Assert.AreEqual(association, controller.Association);

            // the association is empty
            controller.UpdateView();

            // the relation is empty, an exception will be thrown, accept will be false
            Assert.IsFalse(controller.Accept());

            var relValue  = "test relation";
            var relPerson = tree.CreateIndividual();

            // substitutes of values
            view.Relation.Text.Returns(relValue);
            baseWin.Context.SelectPerson(null, TargetMode.tmNone, GDMSex.svUnknown).Returns(relPerson);

            controller.SetPerson();

            Assert.IsTrue(controller.Accept());
            Assert.AreEqual(relValue, association.Relation);
            Assert.AreEqual(relPerson, tree.GetPtrValue(association));
        }
Beispiel #2
0
        public void Test_Common()
        {
            var view = Substitute.For <IAssociationEditDlg>();

            Assert.IsNull(view.Association);
            Assert.IsNotNull(view.Person);
            Assert.IsNotNull(view.Relation);

            var controller = new AssociationEditDlgController(view);

            Assert.IsNotNull(controller);

            controller.Association = fAssociation;
            Assert.AreEqual(fAssociation, controller.Association);

            controller.Accept();

            //controller.SetPerson();

            /*Assert.Throws(typeof(ArgumentNullException), () => { AppHost.Instance.LoadBase(null, null); });*/
        }