Exemplo n.º 1
0
        public async Task DBFiles_Provider_01_ByReference()
        {
            ByReference Obj = new ByReference()
            {
                Default = DBFilesBTreeTests.CreateDefault(100),
                Simple  = DBFilesBTreeTests.CreateSimple(100)
            };

            await this.provider.Insert(Obj);

            ObjectBTreeFile File = await this.provider.GetFile("Default");

            await DBFilesBTreeTests.AssertConsistent(File, this.provider, 3, Obj, true);

            Console.Out.WriteLine(await DBFilesBTreeTests.ExportXML(File, "Data\\BTree.xml"));

            Assert.AreNotEqual(Guid.Empty, Obj.ObjectId);
            Assert.AreNotEqual(Guid.Empty, Obj.Default.ObjectId);
            Assert.AreNotEqual(Guid.Empty, Obj.Simple.ObjectId);

            ByReference Obj2 = await this.provider.LoadObject <ByReference>(Obj.ObjectId);

            DBFilesObjectSerializationTests.AssertEqual(Obj2.Default, Obj.Default);
            DBFilesObjectSerializationTests.AssertEqual(Obj2.Simple, Obj.Simple);
        }
Exemplo n.º 2
0
        public async Task TestInitialize()
        {
            if (!File.Exists(DBFilesBTreeTests.MasterFileName + ".bak") ||
                !File.Exists(DBFilesBTreeTests.DefaultFileName + ".bak") ||
                !File.Exists(DBFilesBTreeTests.DefaultBlobFileName + ".bak") ||
                !File.Exists(DBFilesBTreeTests.DefaultLabelsFileName + ".bak"))
            {
                Assert.Inconclusive("No backup files to test against.");
            }

            if (File.Exists(DBFilesBTreeTests.MasterFileName))
            {
                File.Delete(DBFilesBTreeTests.MasterFileName);
            }

            if (File.Exists(DBFilesBTreeTests.DefaultFileName))
            {
                File.Delete(DBFilesBTreeTests.DefaultFileName);
            }

            if (File.Exists(DBFilesBTreeTests.DefaultBlobFileName))
            {
                File.Delete(DBFilesBTreeTests.DefaultBlobFileName);
            }

            if (File.Exists(DBFilesBTreeTests.DefaultLabelsFileName))
            {
                File.Delete(DBFilesBTreeTests.DefaultLabelsFileName);
            }

            File.Copy(DBFilesBTreeTests.MasterFileName + ".bak", DBFilesBTreeTests.MasterFileName);
            File.Copy(DBFilesBTreeTests.DefaultFileName + ".bak", DBFilesBTreeTests.DefaultFileName);
            File.Copy(DBFilesBTreeTests.DefaultBlobFileName + ".bak", DBFilesBTreeTests.DefaultBlobFileName);
            File.Copy(DBFilesBTreeTests.DefaultLabelsFileName + ".bak", DBFilesBTreeTests.DefaultLabelsFileName);

            int BlockSize = this.LoadBlockSize();

#if LW
            this.provider = await FilesProvider.CreateAsync(DBFilesBTreeTests.Folder, DBFilesBTreeTests.CollectionName, BlockSize, 10000, Math.Max(BlockSize / 2, 1024), Encoding.UTF8, 10000);
#else
            this.provider = await FilesProvider.CreateAsync(DBFilesBTreeTests.Folder, DBFilesBTreeTests.CollectionName, BlockSize, 10000, Math.Max(BlockSize / 2, 1024), Encoding.UTF8, 10000, true);
#endif
            this.file = await this.provider.GetFile(DBFilesBTreeTests.CollectionName);

            this.start = DateTime.Now;

            await DBFilesBTreeTests.ExportXML(this.file, "Data\\BTreeBefore.xml");
        }
Exemplo n.º 3
0
        public async Task DBFiles_RetryLastTest_02_Retry_Delete()
        {
            FileStatistics StatBefore = (await this.file.ComputeStatistics()).Key;
            Guid           ObjectId   = this.LoadObjectId();

            try
            {
                await this.file.DeleteObject(ObjectId);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(await DBFilesBTreeTests.ExportXML(this.file, "Data\\BTreeError.xml"));
                ExceptionDispatchInfo.Capture(ex).Throw();
            }

            Console.Out.WriteLine(await DBFilesBTreeTests.ExportXML(this.file, "Data\\BTreeAfter.xml"));

            await DBFilesBTreeTests.AssertConsistent(this.file, this.provider, (int)(StatBefore.NrObjects - 1), null, true);
        }