예제 #1
0
        public void ShiftCreatesSubDir()
        {
            using (var dir = new TempDirectory())
            {
                IHive hive = new FileHive(dir.Value().FullName, "cars");
                hive = hive.Shifted("product");
                hive.Catalog().Add("2CV");

                using (var cell =
                           hive.Comb("2CV").Cell("data")
                       )
                {
                    cell.Update(new InputOf("bytes over bytes here..."));
                    Assert.True(
                        Directory.Exists(
                            new Normalized(
                                Path.Combine(
                                    dir.Value().FullName,
                                    "product",
                                    "2CV"
                                    )
                                ).AsString()
                            )
                        );
                }
            }
        }
예제 #2
0
        public void UpdatesComplexWithFileHive()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "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();
            }
        }
예제 #3
0
 public void FindsComb()
 {
     using (var dir = new TempDirectory())
     {
         var hive = new FileHive(dir.Value().FullName, "product");
         hive.Catalog().Add("2CV");
         Assert.NotEmpty(
             hive.Catalog().List()
             );
     }
 }
예제 #4
0
 public void DeliversNameInParallel()
 {
     using (var dir = new TempDirectory())
     {
         var hive = new FileHive(dir.Value().FullName, "product");
         Parallel.For(0, Environment.ProcessorCount << 4, i =>
                 {
                 Assert.Equal("product", hive.Scope());
             });
     }
 }
예제 #5
0
        public void PrependsScopeToCombName()
        {
            using (var dir = new TempDirectory())
            {
                IHive hive    = new FileHive(dir.Value().FullName, "cockpit");
                var   shifted = hive.Shifted("prepend-this");
                shifted.Catalog().Add("an-entry");

                Assert.StartsWith("prepend-this",
                                  shifted.Comb("an-entry").Name()
                                  );
            }
        }
예제 #6
0
        public void WritesPropsInParallel()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "product");

                Parallel.For(0, Environment.ProcessorCount << 4, i =>
                        {
                        hive.Comb("2CV").Props().Refined("looping", "louie");
                    });

                Assert.Equal("louie", hive.Comb("2CV").Props().Value("looping"));
            }
        }
예제 #7
0
 public void ShiftsScope()
 {
     using (var dir = new TempDirectory())
     {
         IHive hive = new FileHive(dir.Value().FullName, "product");
         hive.Catalog().Add("2CV");
         hive = hive.Shifted("machine");
         hive.Catalog().Add("DrRobotic");
         Assert.Equal(
             1,
             hive.Catalog().List().Count
             );
     }
 }
예제 #8
0
        public void AddsInParallel()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "product");

                Parallel.For(0, Environment.ProcessorCount << 4, (i) =>
                        {
                        hive.Catalog().Add("supercar");
                    });

                Assert.Equal(1, hive.Catalog().List().Count);
            }
        }
예제 #9
0
 public void WorksWithFileHive()
 {
     using (var dir = new TempDirectory())
     {
         var valve = new LocalSyncPipe();
         var hive  = new FileHive(dir.Value().FullName, "product");
         hive.Catalog().Add("2CV");
         Parallel.For(0, Environment.ProcessorCount << 4, i =>
                 {
                 hive.Comb("2CV");
                 hive.Scope();
                 hive.HQ();
             });
     }
 }
예제 #10
0
        public void ShiftsHQ()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "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());
            }
        }
예제 #11
0
        public void CreatesHiveFolder()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "product");
                hive.Catalog().Add("2CV");

                using (var cell = hive.Comb("2CV").Cell("Some-testing-item"))
                {
                    cell.Update(new InputOf("I am a very cool testdata string"));
                    var productDir = Path.Combine(dir.Value().FullName, "product");
                    Assert.True(
                        Directory.Exists(productDir),
                        $"Directory '{productDir}' doesn't exist"
                        );
                }
            }
        }
예제 #12
0
        public void WritesPropsWithDecode()
        {
            using (var dir = new TempDirectory())
            {
                IHive hive = new FileHive(dir.Value().FullName, "product");
                hive = hive.Shifted("still-parallel");

                hive.Comb("an id").Props().Refined("the,:prop", "the:,value");
                Assert.NotEqual(
                    "the,:prop:the:,value\r",
                    new TextOf(
                        hive.Comb("an id")
                        .Cell("props.cat")
                        .Content()
                        ).AsString()
                    );
            }
        }
예제 #13
0
        public void DeliversHQInParallelAfterShift()
        {
            using (var dir = new TempDirectory())
            {
                IHive hive = new FileHive(dir.Value().FullName, "product");
                hive = hive.Shifted("still-parallel");

                var first = true;
                Parallel.For(0, Environment.ProcessorCount << 4, i =>
                        {
                        if (!first)
                        {
                            hive.Catalog().Remove("X");
                            first = false;
                        }
                        hive.Catalog().Add("X");
                    });
                Assert.True(hive.Catalog().Has("X"));
            }
        }
예제 #14
0
        public void DeliversHQInParallel()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "product");

                Parallel.For(0, Environment.ProcessorCount << 4, i =>
                        {
                        var xoc = hive.HQ().Xocument("test");
                        xoc.Modify(
                            new Directives()
                            .Xpath("/test")
                            .AddIf("result")
                            .Set("passed")
                            );
                        Assert.Equal(
                            "passed",
                            hive.HQ().Xocument("test").Value("/test/result/text()", "")
                            );
                    });
            }
        }
예제 #15
0
        public void WritesPropsWhenShifted()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "product");

                Parallel.For(0, 256, (i) =>
                {
                    var id = $"mech-{i}";
                    hive.Shifted("machine").Catalog().Add(id);
                    hive.Shifted("machine")
                    .Comb(id)
                    .Props()
                    .Refined("checksum", id);
                });

                Parallel.ForEach(hive.Shifted("machine").Catalog().List(), comb =>
                {
                    Assert.Equal(comb.Name(), $"machine/{comb.Props().Value("checksum")}");
                });
            }
        }
예제 #16
0
        public void RemembersCombCell()
        {
            using (var dir = new TempDirectory())
            {
                var hive = new FileHive(dir.Value().FullName, "product");
                using (var cell = hive.Comb("2CV").Cell("Some-testing-item")
                       )
                {
                    cell.Update(new InputOf("I am a very cool testdata string"));
                }

                using (var cell = hive.Comb("2CV").Cell("Some-testing-item")
                       )
                {
                    Assert.Equal(
                        "I am a very cool testdata string",
                        new TextOf(
                            cell.Content()
                            ).AsString()
                        );
                }
            }
        }
예제 #17
0
 public void CreatesCombFolder()
 {
     using (var dir = new TempDirectory())
     {
         var hive = new FileHive(dir.Value().FullName, "product");
         using (var cell =
                    hive.Comb("2CV", true).Cell("Some-testing-item")
                )
         {
             cell.Update(new InputOf("I am a very cool testdata string"));
             var combDir = Path.Combine(dir.Value().FullName, "product", "2CV");
             Assert.True(
                 Directory.Exists(
                     new Normalized(
                         combDir
                         ).AsString()
                     )
                 ,
                 $"Directory '{combDir}' doesn't exist"
                 );
         }
     }
 }