示例#1
0
        public void Add_revision_with_duplicate_name_should_throw()
        {
            var target = new Target(new ServerFake(), new DatabaseFake { VerifyConnectionValue = false });

            target.AddRevision(new Revision("name", null));

            Assert.Throws<GarlicException>(() => target.AddRevision(new Revision("name", null)));
        }
示例#2
0
        public void Sync_should_call_down_when_up_throws_and_rethrow()
        {
            var database = new DatabaseFake { VerifyConnectionValue = true };
            database.SetRevision("Current");
            var target = new Target(new ServerFake(), database);
            target.AddRevision(new Revision("Current", null));
            var downCalled = false;
            target.AddRevision(new Revision("Throws", (s, d) => { throw new Exception(); }, (s, d) => downCalled = true));

            Assert.Throws<Exception>(() => target.Sync(false));
            Assert.True(downCalled);
        }
示例#3
0
        public void Sync_should_set_revision_after_successful_apply()
        {
            var database = new DatabaseFake { VerifyConnectionValue = true };
            database.SetRevision("Current");
            var target = new Target(new ServerFake(), database);
            target.AddRevision(new Revision("First", null));
            target.AddRevision(new Revision("Current", null));
            target.AddRevision(new Revision("After", (s, d) => d = d));

            target.Sync(false);

            Assert.That(database.GetRevision(), Is.EqualTo("After"));
        }
示例#4
0
        public void Sync_should_trigger_after_sync_event()
        {
            var database = new DatabaseFake { VerifyConnectionValue = true };
            database.SetRevision("Current");
            var target = new Target(new ServerFake(), database);
            target.AddRevision(new Revision("Current", null));
            target.AddRevision(new Revision("After", (s, d) => d = d ));
            var afterSynced = false;
            target.AfterSync += (s, d) => afterSynced = true;

            target.Sync(false);

            Assert.True(afterSynced);
        }
示例#5
0
        public void Sync_with_create_flag_should_create_initial_revision()
        {
            var database = new DatabaseFake { VerifyConnectionValue = false };
            var target = new Target(new ServerFake(), database);
            target.AddRevision(new Revision("create", (s, d) => database.VerifyConnectionValue = true));
            target.Sync();

            Assert.That(database.GetRevision(), Is.EqualTo("create"));
        }
示例#6
0
        public void Sync_without_create_flag_should_throw_when_database_can_not_be_opened()
        {
            var target = new Target(new ServerFake(), new DatabaseFake { VerifyConnectionValue = false });

            Assert.Throws<GarlicException>(() => target.Sync(createDatabase: false));
        }
示例#7
0
        public void Sync_with_revision_that_can_not_be_found_should_throw()
        {
            var database = new DatabaseFake { VerifyConnectionValue = false };
            database.SetRevision("Unknown revision");
            var target = new Target(new ServerFake(), new DatabaseFake { VerifyConnectionValue = true });
            target.AddRevision(new Revision("Something", null));

            Assert.Throws<RevisionNotFoundException>(() => target.Sync(createDatabase: false));
        }
示例#8
0
        public void Sync_with_revision_should_apply_revisions_after()
        {
            var database = new DatabaseFake { VerifyConnectionValue = true };
            database.SetRevision("Current");
            var target = new Target(new ServerFake(), database);
            target.AddRevision(new Revision("First", null));
            target.AddRevision(new Revision("Current", null));
            bool applied1 = false;
            target.AddRevision(new Revision("After 1", (s, d) => applied1 = true ));
            bool applied2 = false;
            target.AddRevision(new Revision("After 2", (s, d) => applied2 = true ));

            target.Sync(false);

            Assert.True(applied1 && applied2);
        }
示例#9
0
        public void Sync_with_create_flag_should_use_first_revision_to_create_database()
        {
            var database = new DatabaseFake { VerifyConnectionValue = false };
            var target = new Target(new ServerFake(), database);
            var appliedFirstRevision = false;
            target.AddRevision(new Revision("create", (s, d) =>
                {
                    appliedFirstRevision = true;
                    database.VerifyConnectionValue = true;
                }));

            target.Sync();

            Assert.True(appliedFirstRevision);
        }