Beispiel #1
0
        public void WorksParallelWithRamHive()
        {
            var hive    = new RamHive("product");
            var machine = "Dr.Robotic";

            new ParallelFunc(() =>
            {
                var id = Guid.NewGuid().ToString();
                hive.Shifted("to-the-left").Catalog().Add(machine);

                var content = Guid.NewGuid().ToString();
                hive.Shifted("to-the-left")
                .Comb(machine)
                .Cell(id)
                .Update(new InputOf(content));

                Assert.Equal(
                    content,
                    new TextOf(
                        hive.Shifted("to-the-left")
                        .Comb(machine)
                        .Cell(id)
                        .Content()
                        ).AsString()
                    );
                return(true);
            },
                             256,
                             10000
                             ).Invoke();
        }
Beispiel #2
0
        public void WritesPropsWhenShifted()
        {
            var hive = new RamHive("product");

            for (int i = 0; i < 256; i++)
            {
                var id = $"mech-{i}";
                hive.Shifted("machine").Catalog().Add(id);
                hive.Shifted("machine").Comb(id).Props().Refined("checksum", id);
            }

            foreach (var comb in hive.Shifted("machine").Catalog().List())
            {
                Assert.Equal(comb.Name(), $"machine/{comb.Props().Value("checksum")}");
            }
        }
Beispiel #3
0
        public void WritesComplexInParallel()
        {
            var hive = new RamHive("product");

            for (int i = 0; i < 256; i++)
            {
                var id = $"mech-{i}";
                hive.Shifted("machine").Catalog().Add(id);
                hive.Shifted("machine").Comb(id).Props().Refined("checksum", id);
            }

            Parallel.For(0, 256, i =>
            {
                var id = $"mech-{i}";
                using (var xoc = hive.Shifted("machine").Comb(id).Xocument("stuff.xml"))
                {
                    var name = xoc.Value($"/stuff/thing/text()", "");
                    xoc.Modify(new Directives().Xpath("//name").Set(Guid.NewGuid()));
                    using (var xoc2 = hive.Shifted("machine").Comb(id).Xocument("stuff.xml"))
                    {
                        var name2 = xoc.Value($"/stuff/thing/text()", "");
                        xoc2.Modify(new Directives().Xpath("/stuff").AddIf("thing").Set(Guid.NewGuid()));
                        using (var xoc3 = hive.Shifted("machine").Comb(id).Xocument("stuff.xml"))
                        {
                            var name3 = xoc.Value($"/stuff/thing/text()", "");
                            xoc3.Modify(new Directives().Xpath("/stuff").AddIf("thing").Set(Guid.NewGuid()));
                        }
                    }
                }
                Assert.Equal(1, hive.Shifted("machine").Comb(id).Xocument("stuff.xml").Nodes("//thing").Count);
            });
        }
Beispiel #4
0
        public void PrependsScopeToCombName()
        {
            using (var dir = new TempDirectory())
            {
                var hive    = new RamHive("product");
                var shifted = hive.Shifted("prepend-this");
                shifted.Catalog().Add("an-entry");

                Assert.StartsWith("prepend-this",
                                  shifted.Comb("an-entry").Name()
                                  );
            }
        }
Beispiel #5
0
 public void ShiftsScope()
 {
     using (var dir = new TempDirectory())
     {
         IHive hive = new RamHive("product");
         hive.Catalog().Add("2CV");
         hive = hive.Shifted("machine");
         hive.Catalog().Add("DrRobotic");
         Assert.Equal(
             1,
             hive.Catalog().List().Count
             );
     }
 }
Beispiel #6
0
        public void ShiftsHQ()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new RamHive("cockpit");
                hive.Catalog().Add("log");

                var shifted = hive.Shifted("factory");
                shifted.Catalog().Add("booyaa");

                var shiftedAgain = shifted.Shifted("cockpit");

                Assert.Contains("log", shiftedAgain.Catalog().List()[0].Name());
            }
        }