Esempio n. 1
0
        public void AddEntityTest()
        {
            var tmp = Path.Combine(Path.GetTempPath(), "Ptolemy.Repository", "Test");

            Directory.CreateDirectory(tmp);

            var root = Path.Combine(tmp, "dbRoot");

            Directory.CreateDirectory(root);

            var pe = GenerateDummyParameters().First();

            try {
                using var hub = new DbHub(CancellationToken.None, root, 1, null);
                var key = hub.AddDb(pe);

                hub.AddEntity(key, new ResultEntity {
                    Sweep  = 1, Seed = 2,
                    Signal = "signal", Time = 0,
                    Value  = 1
                });

                hub.CloseDb(key);

                var repo = new ReadOnlyRepository(Path.Combine(root, $"{key}.sqlite"));
                Func <Map <string, decimal>, bool> f = m => m[$"signal/{0M:E5}"] == 1;
                var res = repo.Aggregate(
                    CancellationToken.None, new[] { "signal" }, new[] { f }, 2, new (long start, long end)[] { (1, 10) },
Esempio n. 2
0
        public void AddDbTest()
        {
            var tmp = Path.Combine(Path.GetTempPath(), "Ptolemy.Repository", "Test");

            Directory.CreateDirectory(tmp);

            var root = Path.Combine(tmp, "dbRoot");

            Directory.CreateDirectory(root);

            var pe = GenerateDummyParameters().First();

            try {
                using var hub = new DbHub(CancellationToken.None, root, 10, null);
                var key = hub.AddDb(pe);
                Assert.Equal(pe.Hash(), key);

                hub.CloseDb(pe);

                key = hub.AddDb(pe);
                Assert.Equal(pe.Hash(), key);
            }
            finally {
                Directory.Delete(tmp, true);
            }
        }