Пример #1
0
        public void Test_Branching_MultipleChangesAcrossMultipleObjects()
        {
            var los   = new LosObjectSystem();
            var prime = los.Master;

            prime.Put(new Hello()
            {
                One   = "Howdy",
                Two   = "Hi",
                Three = "Hello"
            });

            prime.Put(new GoodBye()
            {
                One   = "Bye",
                Two   = "Goodby",
                Three = "Later"
            });

            var master = prime.Branch();

            // creates a branch of the root and changes some properties
            var hello = master.Get <Hello>();

            hello.One = "Yo";
            hello.Two = null;

            var bHello = master.Get <Hello>();

            // all these assertions are true
            Assert.AreEqual("Yo", bHello.One);
            Assert.IsNull(bHello.Two);
            // note that Three was never set in the branch, therefore
            // the current value in the master cascades to the branch
            Assert.AreEqual("Hello", bHello.Three);

            // Note that changing properties in the branch did not change the master
            var mHello = prime.Get <Hello>();

            Assert.AreEqual("Howdy", mHello.One);
            Assert.AreEqual("Hi", mHello.Two);
            Assert.AreEqual("Hello", mHello.Three);
        }
Пример #2
0
        public void Test_Branching_Basic()
        {
            var application = new Application()
            {
                Title = "TPS Report Manager 3000"
            };

            var los    = new LosObjectSystem();
            var master = los.Master;

            master.Put(application);
            var branch = master.Branch();

            Assert.AreEqual("TPS Report Manager 3000", branch.Get <Application>().Title);

            // now change the title
            branch.Get <Application>().Title = "TPS Report Manager 3000 + 1";

            // the branch title should be updated and the master title should not have changed
            Assert.AreEqual("TPS Report Manager 3000", master.Get <Application>().Title);
            Assert.AreEqual("TPS Report Manager 3000 + 1", branch.Get <Application>().Title);
        }
Пример #3
0
        public void TestBranching_MultipleBranchSingleParent()
        {
            var application = new Application()
            {
                Title = "TPS Report Manager 3000"
            };

            var los    = new LosObjectSystem();
            var master = los.Master;

            master.Put(application);

            var branches = new List <ILosRoot>();

            for (int i = 1; i <= 10; i++)
            {
                var branch = master.Branch();
                branches.Add(branch);

                Assert.AreEqual("TPS Report Manager 3000", branch.Get <Application>().Title);

                // now change the title
                var title = "TPS Report Manager " + (3000 + i).ToString();
                branch.Get <Application>().Title = title;

                // the branch title should be updated and the master title should not have changed
                Assert.AreEqual("TPS Report Manager 3000", master.Get <Application>().Title);
                Assert.AreEqual(title, branch.Get <Application>().Title);
            }
            for (int i = 1; i <= 10; i++)
            {
                var branch = branches[i - 1];
                var title  = "TPS Report Manager " + (3000 + i).ToString();

                Assert.AreEqual("TPS Report Manager 3000", master.Get <Application>().Title);
                Assert.AreEqual(title, branch.Get <Application>().Title);
            }
        }
Пример #4
0
        public void Test_Nesting()
        {
            var los   = new LosObjectSystem();
            var prime = los.Master;

            // populate the object system with some data
            prime.Put(new Application()
            {
                Title      = "TPS Report Manager 3000",
                Navigation = new Navigation()
                {
                    HomeUrl = "http://localhost:8080/Lowkoder",
                    Items   = new List <NavigationItem>()
                    {
                        new NavigationItem()
                        {
                            Label = "Home",
                            Uri   = "/"
                        }
                    }
                }
            });

            var master = prime.Branch();                           // save the data to create the master branch

            Assert.AreEqual("root:0", master.Revision.ToString()); /// the master branch always has revision 0

            // we should get the title that we created
            Assert.AreEqual("TPS Report Manager 3000", master.Get <Application>().Title);

            // now change the title
            master.Get <Application>().Title = "TPS Report Manager 3000 + 1";
            Assert.AreEqual("root:0", master.Revision.ToString());

            // the branch title should be updated and the master title should not have changed
            Assert.AreEqual("TPS Report Manager 3000", prime.Get <Application>().Title);
            Assert.AreEqual("TPS Report Manager 3000 + 1", master.Get <Application>().Title);
        }
Пример #5
0
        public void Test_EditFields()
        {
            var los    = new LosObjectSystem();
            var master = los.Master;

            master.Put(new LowkoderRoot());

            var lowkoderRoot = master.Get <LowkoderRoot>();

            lowkoderRoot.Context.SiteSpecification.Model = new TestStarship();
            var modelMetadata = Core.Metadata.TypeDescriptor.ForSystemType(typeof(TestStarship));

            lowkoderRoot.Context.SiteSpecification.ModelType = modelMetadata;

            var propertyRoots = new List <ILosRoot>();
            var memberPaths   = new Dictionary <ILosRoot, MemberPath>();

            foreach (var property in modelMetadata.Properties)
            {
                var memberPath = property.ToMemberPath();

                var propertyRoot = master.Branch();
                var lkRoot       = propertyRoot.Get <LowkoderRoot>();
                lkRoot.Context.SiteSpecification.ModelMember = memberPath;

                propertyRoots.Add(propertyRoot);
                memberPaths.Add(propertyRoot, memberPath);
            }

            foreach (var propertyRoot in propertyRoots)
            {
                var originalPath = memberPaths[propertyRoot];
                var lkRoot       = propertyRoot.Get <LowkoderRoot>();
                var savedPath    = lkRoot.Context.SiteSpecification.ModelMember;
                Assert.AreEqual(originalPath.TargetProperty.Name, savedPath.TargetProperty.Name);
            }
        }