Manages database migrations that are needed to ensure that working copies of a project have the up-to-date database structure.
This migrator requires access to an ISettings service that can read and write a a DATABASE_VERSION setting. Since ConfigFileSettings does not have write support, you will either need to use DatabaseSettings or reimplement a settings operator. The setting will need to be in existence before this operation will execute correctly.
This class is commonly used inside an implementation of IApplicationVersionUpgrader . See the tutorials for usage examples.
        public void Constructor_SetsPercentageCompleteToCorrectValue(int start, int step, int total, decimal expectedPercentage)
        {
            //---------------Set up test pack-------------------
            var conn = Substitute.For<IDatabaseConnection>();
            var migrator = new DBMigrator(conn);
            
            //---------------Assert Precondition----------------
            Assert.IsNotNull(migrator);

            //---------------Execute Test ----------------------
            var e = new DBMigratorEventArgs((uint)start, (uint)step, (uint)total);
            var propVal = e.PercentageComplete;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedPercentage, propVal);
        }
示例#2
0
        public void SetupFixture()
        {
            GlobalRegistry.ApplicationName = appName;
            GlobalRegistry.ApplicationVersion = appVersion;
            GlobalRegistry.DatabaseVersion = dbVersion;
            GlobalRegistry.Settings = settings;
            GlobalRegistry.UIExceptionNotifier = exNotifier;

            itsConn = Substitute.For<IDatabaseConnection>();
            itsDbMigrator = new DBMigrator(itsConn);
            itsDbMigrator.AddMigration(1, "migration1;");
            itsDbMigrator.AddMigration(2, "migration2;");
            itsDbMigrator.AddMigration(3, "migration3;");

            _itsSettings = Substitute.For<ISettings>();
        }
示例#3
0
        public void SetupFixture()
        {
            GlobalRegistry.ApplicationName = appName;
            GlobalRegistry.ApplicationVersion = appVersion;
            GlobalRegistry.DatabaseVersion = dbVersion;
            GlobalRegistry.Settings = settings;
            GlobalRegistry.UIExceptionNotifier = exNotifier;

            itsConnMock = new DynamicMock(typeof(IDatabaseConnection));
            itsConn = (IDatabaseConnection)itsConnMock.MockInstance;
            itsDbMigrator = new DBMigrator(itsConn);
            itsDbMigrator.AddMigration(1, "migration1;");
            itsDbMigrator.AddMigration(2, "migration2;");
            itsDbMigrator.AddMigration(3, "migration3;");

            itsSettingsMock = new DynamicMock(typeof(ISettings));
            _itsSettings = (ISettings)itsSettingsMock.MockInstance;
        }
        public void Constructor_SetsCurrentStepToSpecifiedStep()
        {
            //---------------Set up test pack-------------------
            var conn = Substitute.For<IDatabaseConnection>();
            var migrator = new DBMigrator(conn);
            var step = (uint)TestUtil.GetRandomInt(1, 50);
            var totalSteps = (uint)TestUtil.GetRandomInt((int)step, (int)step + 50);
            
            //---------------Assert Precondition----------------
            Assert.AreNotEqual(0, step);
            Assert.IsNotNull(migrator);

            //---------------Execute Test ----------------------
            var e = new DBMigratorEventArgs(1, step, totalSteps);
            var propVal = e.CurrentStep;
            //---------------Test Result -----------------------
            Assert.AreEqual(step, propVal);
        }