예제 #1
0
        public async Task CouldCreateRepoAsync()
        {
            var path = TestUtils.GetPath(clear: true);
            var mdm  = new MetadataManager(path);

            var dataPath = new DataPath("~/test/");
            var testRow  = await mdm.CreateRepoAsync(dataPath);

            var testRow1 = await mdm.CreateRepoAsync(dataPath);

            Assert.IsNull(testRow1.PK);

            Assert.IsTrue(testRow.PK != null);
            Console.WriteLine(testRow.PK);
            Assert.AreEqual(1, testRow.ParentId);

            for (int i = 0; i < 100; i++)
            {
                dataPath = new DataPath(dataPath + $"sub{i}/");
                var testRecordSub = await mdm.CreateRepoAsync(dataPath);

                Assert.IsTrue(testRecordSub.PK != null);
                Console.WriteLine(i + " - " + testRecordSub.PK.Length + ": " + testRecordSub.PK);
                Assert.AreEqual(testRow.RepoId, testRecordSub.ParentId);
                testRow = testRecordSub;

                var getRepo = await mdm.GetMetadataRecordByPathAsync(dataPath);

                Assert.IsTrue(getRepo.PK != null);
            }

            mdm.Dispose();
        }
예제 #2
0
        public async Task CannotCreateStreamWithTheSameNameAsRepoAsync()
        {
            var path = TestUtils.GetPath(clear: true);
            var mdm  = new MetadataManager(path);

            var record = await mdm.CreateRepoAsync(new DataPath("~/test/"));

            Assert.IsTrue(record.PK != null);

            var repo1 = await mdm.GetMetadataRecordByPathAsync(new DataPath("~/test/"));

            Assert.AreEqual(1, repo1.ParentId);

            record = await mdm.CreateStreamAsync(new DataPath("~/test"), new Metadata(""), default);

            Assert.IsFalse(record.PK != null);
        }