public void should_drop_database_when_deployed_with_dropDatabase_option()
 {
     using (var sut = new TemporaryDatabase())
     {
         sut.Deploy(string.Empty, string.Empty, true);
         Assert.True(!sut.Exists());
     }
 }
        public void should_remove_database_when_disposed()
        {
            var sut = new TemporaryDatabase();

            sut.Deploy();
            sut.Dispose();
            Assert.That(sut.Exists(), Is.False);
        }
 public void should_create_tables_and_sprocs_when_deployed()
 {
     using (var sut = new TemporaryDatabase())
     {
         sut.Deploy(Path.Combine(Assembly.GetExecutingAssembly().Directory(), "Scripts1"));
         Assert.That(sut.GetTables().Select(x => x.Name), Has.Member("Table1"));
     }
 }
 public void SetUp()
 {
     if ((requirements & TheDatabase.MustBeFresh) == TheDatabase.MustBeFresh || Database == null)
     {
         Database = new TemporaryDatabase();
         Database.CreateAndDeploy();
     }
 }
        public void should_stamp_repository_path_when_deployed()
        {
            const string repositoryPath = "testrepository";

            using (var sut = new TemporaryDatabase())
            {
                sut.Deploy(Path.Combine(Assembly.GetExecutingAssembly().Directory(), "Scripts1"), repositoryPath);
                Assert.That(sut.ReadRepository(), Is.EqualTo(repositoryPath));
            }
        }
 public void SetUp()
 {
     if (!IntegrationTestOptions.Firebird.IsEnabled)
     {
         Assert.Ignore();
     }
     _temporaryDatabase = new TemporaryDatabase(
         IntegrationTestOptions.Firebird,
         _firebirdLibraryProber);
 }
        public void should_stamp_version_from_default_buildinfo_file_when_deployed()
        {
            // This version number is set in _BuildInfo.txt which lives at the root of the database scripts
            const string currentVersion = "1.1.1.1";

            using (var sut = new TemporaryDatabase())
            {
                sut.Deploy(Path.Combine(Assembly.GetExecutingAssembly().Directory(), "Scripts1"));
                Assert.That(sut.ReadVersion(), Is.EqualTo(currentVersion));
            }
        }
        public void TearDown()
        {
            if (_temporaryDatabase == null)
            {
                return;
            }

            FbDatabase.DropDatabase(_temporaryDatabase.ConnectionString);
            _temporaryDatabase.Dispose();
            _temporaryDatabase = null;
        }
        public void should_run_restore_from_backup_and_then_deploy()
        {
            var restoreOptions =
                new DatabaseRestoreOptions(Path.Combine(Assembly.GetExecutingAssembly().Directory(), "ensconcedb.bak"));

            using (var sut = new TemporaryDatabase(restoreOptions))
            {
                sut.Deploy(Path.Combine(Assembly.GetExecutingAssembly().Directory(), "Scripts1"));
                Assert.That(sut.GetTables().Select(x => x.Name), Has.Member("Table1"));
                Assert.That(sut.GetTables().Select(x => x.Name), Has.Member("Table2"));
            }
        }
        public void should_stamp_version_from_environment_variable_when_deployed()
        {
            // This version number is set in _BuildInfo.txt which lives at the root of the database scripts
            const string currentVersion = "1.1.1.2";

            System.Environment.SetEnvironmentVariable("PackageVersion", currentVersion);
            using (var sut = new TemporaryDatabase())
            {
                sut.Deploy(Path.Combine(Assembly.GetExecutingAssembly().Directory(), "Scripts1"));
                Assert.That(sut.ReadVersion(), Is.EqualTo(currentVersion));
            }
        }
        public void should_not_display_fluent_nhibernate_warnings()
        {
            // Get around problem with calling roundhouse dll directly where it continually logs missing type for nhibernate
            var logger = MockRepository.GenerateMock <Logger>();

            using (var sut = new TemporaryDatabase(null, logger))
            {
                sut.Deploy();

                var args = logger.GetArgumentsForCallsMadeOn(x => x.log_a_warning_event_containing(null, null));

                Assert.That(args[0],
                            Has.None.ContainsSubstring(
                                "Had an error building session factory from merged, attempting unmerged. The error:"));
            }
        }
Example #12
0
        /// <summary>
        /// Opens the temporary database.
        /// </summary>
        /// <returns>
        /// A TemporaryDatabase object representing the temporary database for this session
        /// </returns>
        /// <remarks>
        /// Only one temporary database is supported per instance.
        /// </remarks>
        public TemporaryDatabase OpenTemporaryDatabase()
        {
            lock (this)
            {
                this.CheckDisposed();

                if (this.temporaryDatabase == null)
                {
                    this.temporaryDatabase = new TemporaryDatabase(this);
                }

                return this.temporaryDatabase;
            }
        }
Example #13
0
        private void UpgradeData(int dbVersion, IRepository repo)
        {
            if (dbVersion <= 8)
            {
                //8.0
                if (!repo.TableExists("Ruling"))
                {
                    repo.ExecuteBatch(UpdateQueries.CreateRulingTable);
                }

                repo.ExecuteBatch(UpdateQueries.RemoveDuelDeckFromName);
                repo.ExecuteBatch(UpdateQueries.UpdateCodeHeroesMonsterDeck);

                //8.14
                repo.ExecuteBatch(UpdateQueries.UpdateKaladeshInventionGathererName);

                //8.15
                repo.ExecuteBatch(UpdateQueries.DeleteKaladeshInventionGathererIdChange);
            }
            if (dbVersion <= 9)
            {
                repo.ExecuteBatch(UpdateQueries.UpdateKaladeshInventionMissingCard);

                // 9.1
                repo.ExecuteBatch(UpdateQueries.UpdateKaladeshInventionBlock);

                Dictionary <string, string> missing = new Dictionary <string, string> {
                    { "EXP", "Zendikar Expeditions" },
                    { "W16", "Welcome Deck 2016" },
                    { "MPS", "Masterpiece Series: Kaladesh Inventions" },
                };

                foreach (var kv in missing)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.UpdateEditionMissingCode,
                                                   new KeyValuePair <string, object>("@code", kv.Key),
                                                   new KeyValuePair <string, object>("@name", kv.Value));
                }

                if (repo.ColumnExists("Card", "Loyalty") && repo.GetTable("Card").GetColumn("Loyalty").DataType == "INTEGER")
                {
                    foreach (string query in UpdateQueries.ChangeCardLoyaltyColumnType)
                    {
                        repo.ExecuteBatch(query);
                    }
                }

                // 9.2
                repo.ExecuteBatch(UpdateQueries.UpdateAmonkhetInvocationsMissingCard);

                // 9.3
                repo.ExecuteBatch(UpdateQueries.UpdateHourofDevastationReleaseDate);
            }

            if (dbVersion <= 10)
            {
                //10.7
                Dictionary <string, string> updatedcode = new Dictionary <string, string> {
                    { "UGL", "Unglued" },
                    { "CM2", "Commander Anthology 2018" },
                    { "V10", "From the Vault: Relics" },
                    { "V11", "From the Vault: Legends" },
                    { "V12", "From the Vault: Realms" },
                    { "H09", "Premium Deck Series: Sliverss" },
                    { "PD3", "Premium Deck Series: Graveborn" },
                    { "TSP", "Time Spiral" },
                    { "TSB", @"Time Spiral ""Timeshifted""" },
                };

                foreach (var kv in updatedcode)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.UpdateEditionMissingCode,
                                                   new KeyValuePair <string, object>("@code", kv.Key),
                                                   new KeyValuePair <string, object>("@name", kv.Value));
                }

                foreach (string query in UpdateQueries.RemoveWrongCardFromGuildOfRavnica)
                {
                    repo.ExecuteBatch(query);
                }
            }

            if (dbVersion <= 11)
            {
                //11.0
                if (!repo.TableExists("Price"))
                {
                    repo.ExecuteBatch(UpdateQueries.CreatePriceTable);
                }

                foreach (string code in new[] { "'CNS", "EXO" })
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.CorrectHasFoilTrue,
                                                   new KeyValuePair <string, object>("@code", code));
                }

                foreach (string code in new[] { "V15", "V16", "V17", "C15", "C16", "CMA", "C17", "CM2", "C18", "DDO", "DDP", "DDQ", "DDR", "DDS", "DDT", "DDU", "GS1", "E01", "PCA" })
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.CorrectHasFoilFalse,
                                                   new KeyValuePair <string, object>("@code", code));
                }

                //11.1
                repo.ExecuteBatch(UpdateQueries.CorrectBattleBondPartnerNotFlipCard);
            }
            if (dbVersion <= 12)
            {
                //12.0
                if (!repo.TableExists("PreconstructedDeck"))
                {
                    repo.ExecuteBatch(UpdateQueries.CreatePreconstructedDeckTable);
                }
                if (!repo.TableExists("PreconstructedDeckCardEdition"))
                {
                    repo.ExecuteBatch(UpdateQueries.CreatePreconstructedDeckCardEditionTable);
                }

                Dictionary <string, string> updatedcode = new Dictionary <string, string> {
                    { "MD1", "Modern Event Deck 2014" },
                    { "DD1", "Duel Decks: Elves vs. Goblins" },
                    { "DVD", "Duel Decks Anthology, Divine vs. Demonic" },
                    { "GVL", "Duel Decks Anthology, Garruk vs. Liliana" },
                    { "JVC", "Duel Decks Anthology, Jace vs. Chandra" },
                    { "EVG", "Duel Decks Anthology, Elves vs. Goblins" },
                };

                foreach (var kv in updatedcode)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.UpdateEditionMissingCode,
                                                   new KeyValuePair <string, object>("@code", kv.Key),
                                                   new KeyValuePair <string, object>("@name", kv.Value));
                }

                Dictionary <string, string> specialSets = new Dictionary <string, string> {
                    { "CP1", "Magic 2015 Clash Pack" },
                    { "CP2", "Fate Reforged Clash Pack" },
                    { "CP3", "Magic Origins Clash Packs" },
                    { "TD2", "Mirrodin Pure vs. New Phyrexia" },
                    { "DPA", "Duels of the Planeswalkers" },
                    { "DKM", "Deckmasters" },
                    { "ATH", "Anthologies" },
                    { "ITP", "Introductory Two-Player Set" },
                };

                foreach (var kv in specialSets)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.AddNoneGathererSets,
                                                   new KeyValuePair <string, object>("@code", kv.Key),
                                                   new KeyValuePair <string, object>("@name", kv.Value));
                }

                Dictionary <string, string> alternativeCodes = new Dictionary <string, string> {
                    { "OE01", "Archenemy: Nicol Bolas" },
                    { "OPC2", "Planechase 2012 Edition" },
                    { "OARC", "Archenemy" },
                    { "H09", "Slivers" },
                    { "OHOP", "Planechase" },
                    { "P02", "Portal Second Age" },
                };

                foreach (var kv in alternativeCodes)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.AddAlternativeCode,
                                                   new KeyValuePair <string, object>("@code", kv.Key),
                                                   new KeyValuePair <string, object>("@name", kv.Value));
                }

                //12.4
                foreach (string code in new[] { "C19" })
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.CorrectHasFoilFalse,
                                                   new KeyValuePair <string, object>("@code", code));
                }

                //12.5
                Dictionary <string, Tuple <string, string> > vehicleCorrections = new Dictionary <string, Tuple <string, string> >
                {
                    { "Aethersphere Harvester", new Tuple <string, string>("3", "5") },
                    { "Aradara Express", new Tuple <string, string>("8", "6") },
                    { "Ballista Charger", new Tuple <string, string>("6", "6") },
                    { "Bomat Bazaar Barge", new Tuple <string, string>("5", "5") },
                    { "Conqueror's Galleon", new Tuple <string, string>("2", "10") },
                    { "Consulate Dreadnought", new Tuple <string, string>("7", "11") },
                    { "Cultivator's Caravan", new Tuple <string, string>("5", "5") },
                    { "Daredevil Dragster", new Tuple <string, string>("4", "4") },
                    { "Demolition Stomper", new Tuple <string, string>("10", "7") },
                    { "Dusk Legion Dreadnought", new Tuple <string, string>("4", "6") },
                    { "Enchanted Carriage", new Tuple <string, string>("4", "4") },
                    { "Fell Flagship", new Tuple <string, string>("3", "3") },
                    { "Fleetwheel Cruiser", new Tuple <string, string>("5", "3") },
                    { "Heart of Kiran", new Tuple <string, string>("4", "4") },
                    { "Irontread Crusher", new Tuple <string, string>("6", "6") },
                    { "Mizzium Tank", new Tuple <string, string>("3", "2") },
                    { "Mobile Garrison", new Tuple <string, string>("3", "4") },
                    { "Ovalchase Dragster", new Tuple <string, string>("6", "1") },
                    { "Parhelion II", new Tuple <string, string>("5", "5") },
                    { "Peacewalker Colossus", new Tuple <string, string>("6", "6") },
                    { "Renegade Freighter", new Tuple <string, string>("4", "3") },
                    { "Shadowed Caravel", new Tuple <string, string>("2", "2") },
                    { "Silent Submersible", new Tuple <string, string>("2", "3") },
                    { "Sky Skiff", new Tuple <string, string>("2", "3") },
                    { "Skysovereign, Consul Flagship", new Tuple <string, string>("6", "5") },
                    { "Sleek Schooner", new Tuple <string, string>("4", "3") },
                    { "Smuggler's Copter", new Tuple <string, string>("3", "3") },
                    { "Untethered Express", new Tuple <string, string>("4", "4") },
                    { "Weatherlight", new Tuple <string, string>("4", "5") }
                };

                foreach (var kv in vehicleCorrections)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.CorrectVehicle,
                                                   new KeyValuePair <string, object>("@name", kv.Key),
                                                   new KeyValuePair <string, object>("@power", kv.Value.Item1),
                                                   new KeyValuePair <string, object>("@toughness", kv.Value.Item2));
                }
                //12.6
                repo.ExecuteBatch(UpdateQueries.CorrectMystericBoosterText);
            }

            if (dbVersion <= 13)
            {
                //13.0
                if (!repo.ColumnExists("CardEditionsInCollection", "AltArtNumber"))
                {
                    repo.ExecuteBatch(UpdateQueries.AddAltArtColumnToCollection);
                }
                if (!repo.ColumnExists("CardEditionsInCollection", "FoilAltArtNumber"))
                {
                    repo.ExecuteBatch(UpdateQueries.AddFoilAltArtColumnToCollection);
                }
                if (!repo.ColumnExists("Audit", "IsAltArt"))
                {
                    repo.ExecuteBatch(UpdateQueries.AddIsAltArtColumnToAudit);
                    repo.ExecuteBatch(UpdateQueries.UpdateAltArtColumnOfAudit);
                }

                if (!repo.TableExists("CardEditionVariation"))
                {
                    repo.ExecuteBatch(UpdateQueries.CreateCardEditionVariationTable);
                }

                //13.2
                repo.ExecuteParametrizeCommand(UpdateQueries.UpdateSecretLairDropMissingCard,
                                               new KeyValuePair <string, object>("@value", 99));


                //13.4
                if (!repo.TableExists("BackSideModalDoubleFacedCard"))
                {
                    repo.ExecuteBatch(UpdateQueries.CreateBackSideModalDoubleFacedCardTable);
                }

                repo.ExecuteParametrizeCommand(UpdateQueries.UpdateSecretLairDropMissingCard,
                                               new KeyValuePair <string, object>("@value", 122));

                HashSet <string> reverseSideOfFlipLand = new HashSet <string>(new[]
                {
                    //Zendikar Rising
                    "Agadeem, the Undercrypt", "Akoum Teeth", "Bala Ged Sanctuary", "Beyeen Coast",
                    "Blackbloom Bog", "Boulderloft Pathway", "Emeria, Shattered Skyclave", "Glasspool Shore",
                    "Grimclimb Pathway", "Hagra Broodpit", "Jwari Ruins", "Kabira Plateau",
                    "Kazandu Valley", "Kazuul's Cliffs", "Khalni Territory", "Lavaglide Pathway",
                    "Makindi Mesas", "Malakir Mire", "Murkwater Pathway", "Ondu Skyruins",
                    "Pelakka Caverns", "Pillarverge Pathway", "Sea Gate, Reborn", "Sejiri Glacier",
                    "Shatterskull, the Hammer Pass", "Silundi Isle", "Skyclave Basilica", "Song-Mad Ruins",
                    "Spikefield Cave", "Tangled Vale", "Timbercrown Pathway", "Turntimber, Serpentine Wood",
                    "Umara Skyfalls", "Vastwood Thicket", "Valakut Stoneforge", "Zof Bloodbog",
                    //Kaldheim
                    "Hakka, Whispering Raven", "Harnfel, Horn of Bounty", "Kaldring, the Rimestaff", "Mistgate Pathway",
                    "Searstep Pathway", "Slitherbore Pathway", "Sword of the Realms", "Tergrid's Lantern",
                    "The Omenkeel", "The Prismatic Bridge", "The Ringhart Crest", "Throne of Death",
                    "Tibalt, Cosmic Impostor", "Tidechannel Pathway", "Toralf's Hammer", "Valkmira, Protector's Shield",
                    //StixHaven: School of Mages
                    "Augusta, Dean of Order", "Awaken the Blood Avatar", "Deadly Vanity", "Echoing Equation",
                    "Embrose, Dean of Shadow", "Explore the Vastlands", "Flamethrower Sonata", "Imbraham, Dean of Theory",
                    "Journey to the Oracle", "Lisette, Dean of the Root", "Lukka, Wayward Bonder", "Nassari, Dean of Expression",
                    "Restorative Burst", "Revel in Silence", "Search for Blex", "Will, Scholar of Frost",
                });
                foreach (string s in reverseSideOfFlipLand)
                {
                    repo.ExecuteParametrizeCommand(UpdateQueries.InsertBackSideModalDoubleFacedCard,
                                                   new KeyValuePair <string, object>("@name", s));
                }
            }

            if (dbVersion <= 14)
            {
                //14.1
                repo.ExecuteBatch(UpdateQueries.CorrectAECardName);
                repo.ExecuteBatch(UpdateQueries.CorrectAECardPartName);
                repo.ExecuteBatch(UpdateQueries.CorrectKillDestroyCard);
            }

            using (var temporaryDabase = new TemporaryDatabase())
            {
                AddPreconstructedDeckFromReference(repo, temporaryDabase.ConnectionString);
                AddCardEditionVariationFromReference(repo, temporaryDabase.ConnectionString);
            }
        }
Example #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cursor"/> class.
        /// </summary>
        /// <param name="isamSession">The session.</param>
        /// <param name="database">The database.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="tableid">The tableid.</param>
        /// <param name="inInsertMode">if set to <c>true</c> [in insert mode].</param>
        internal Cursor(
            IsamSession isamSession,
            TemporaryDatabase database,
            string tableName,
            JET_TABLEID tableid,
            bool inInsertMode)
        {
            lock (isamSession)
            {
                this.isamSession = isamSession;
                this.database = database;
                this.tableName = tableName;
                this.tableid = tableid;
                this.cleanup = true;
                this.record = new ColumnAccessor(this, isamSession, tableid, RetrieveColumnGrbit.None);
                this.editRecord = new ColumnAccessor(this, isamSession, tableid, RetrieveColumnGrbit.RetrieveCopy);
                this.indexRecord = new ColumnAccessor(this, isamSession, tableid, RetrieveColumnGrbit.RetrieveFromIndex);
                this.isSort = database.Tables[tableName].Type == TableType.Sort;
                this.isSortOrPreSort = database.Tables[tableName].Type == TableType.Sort
                                       || database.Tables[tableName].Type == TableType.PreSortTemporary;
                this.isTempTable = database.Tables[tableName].Type == TableType.Sort
                                   || database.Tables[tableName].Type == TableType.PreSortTemporary
                                   || database.Tables[tableName].Type == TableType.Temporary;
                this.inInsertMode = this.isSortOrPreSort && inInsertMode;
                this.inRetrieveMode = this.isSort && !inInsertMode;
                this.onBeforeFirst = this.isSort && !inInsertMode;

                if (!(this.isSort || (this.isSortOrPreSort && inInsertMode)))
                {
                    this.MoveBeforeFirst();
                }
            }
        }
        public void should_dispose_when_not_deployed()
        {
            var sut = new TemporaryDatabase();

            sut.Dispose();
        }