Пример #1
0
        /// <summary>
        /// Prepares the database for <see cref="TestInsertDirectorySoundGet"/> and returns the root directory.
        /// </summary>
        /// <returns></returns>
        protected async Task <SoundboxDirectory> TestInsertDirectorySoundGet_Prepare()
        {
            SoundboxDirectory directoryRoot = new SoundboxDirectory()
            {
                ID   = Guid.NewGuid(),
                Name = "Directory"
            };
            Sound sound = new Sound()
            {
                ID               = Guid.NewGuid(),
                Name             = "Name",
                FileName         = "FileName",
                AbsoluteFileName = "AbsoluteFileName",
                IconUrl          = "IconUrl",
                Tags             = new string[] { "1", "2", "3" },
                MetaData         = new SoundMetaData()
                {
                    Length = 17
                }
            };

            directoryRoot.AddChild(sound);

            //insert
            await Database.Insert(directoryRoot);

            await Database.Insert(sound);

            return(directoryRoot);
        }
Пример #2
0
        /// <summary>
        /// Template for <see cref="TestInsertDirectoryGet"/> and related tests: compares the given root with the root queried from the database.
        /// </summary>
        /// <param name="directoryRoot"></param>
        /// <returns></returns>
        public async Task TestInsertGet_Template(SoundboxDirectory directoryRoot)
        {
            //get from database
            var fromDb = await Database.Get();

            Assert.IsTrue(Compare(directoryRoot, fromDb, compareDistinct: true, deepCompareParents: true, deepCompareChildren: true));
        }
Пример #3
0
        /// <summary>
        /// Template for <see cref="TestInsertDirectoryCrashGet"/> and related tests: crashes and reopens the database, then compares the given root with the root queried from the database.
        /// </summary>
        /// <param name="directoryRoot"></param>
        /// <returns></returns>
        protected async Task TestInsertGet_Crash_Template(SoundboxDirectory directoryRoot)
        {
            //crash and get
            if (!ReopenDatabaseCrash())
            {
                Assert.Inconclusive("Database provider cannot crash on purpose");
                return;
            }
            var fromDb = await Database.Get();

            Assert.IsTrue(Compare(directoryRoot, fromDb, compareDistinct: true, deepCompareParents: true, deepCompareChildren: true));
        }
Пример #4
0
        /// <summary>
        /// Prepares the database for <see cref="TestInsertDirectoryGet"/> and returns the root directory that has been inserted.
        /// </summary>
        /// <returns></returns>
        protected async Task <SoundboxDirectory> TestInsertDirectoryGet_Prepare()
        {
            SoundboxDirectory directoryRoot = new SoundboxDirectory()
            {
                ID        = Guid.NewGuid(),
                Name      = "Name",
                IconUrl   = "IconUrl",
                Watermark = Guid.NewGuid(),
                Tags      = new string[] { "1", "2", "3" }
            };

            //insert
            await Database.Insert(directoryRoot);

            return(directoryRoot);
        }
Пример #5
0
        /// <summary>
        /// Prepares the database for <see cref="TestInsertDirectoryDirectoryGet"/> and returns the root directory.
        /// </summary>
        /// <returns></returns>
        protected async Task <SoundboxDirectory> TestInsertDirectoryDirectoryGet_Prepare()
        {
            SoundboxDirectory directoryRoot = new SoundboxDirectory()
            {
                ID   = Guid.NewGuid(),
                Name = "Directory"
            };
            SoundboxDirectory directoryChild = new SoundboxDirectory()
            {
                ID      = Guid.NewGuid(),
                Name    = "Name",
                IconUrl = "IconUrl",
                Tags    = new string[] { "1", "2", "3" }
            };

            directoryRoot.AddChild(directoryChild);

            //insert
            await Database.Insert(directoryRoot);

            await Database.Insert(directoryChild);

            return(directoryRoot);
        }
Пример #6
0
        public async Task TestInsertDirectorySoundDirectoryCrashGet()
        {
            SoundboxDirectory directoryRoot = await TestInsertDirectorySoundDirectoryGet_Prepare();

            await TestInsertGet_Crash_Template(directoryRoot);
        }
Пример #7
0
        public async Task TestInsertDirectoryDirectorySoundReopenGet()
        {
            SoundboxDirectory directoryRoot = await TestInsertDirectoryDirectorySoundGet_Prepare();

            await TestInsertGet_Reopen_Template(directoryRoot);
        }