Beispiel #1
0
        public void OpenThrowsIfDatabaseTypeDoesNotExist()
        {
            var connectionInfo = new MockDbConnectionInfo
            {
                ConnectionStringName = "Test1"
            };

            var result = Assert.Throws <ArgumentException>(() => MockDatabaseProvider.Open(connectionInfo));

            Assert.AreEqual("connectionInfo", result.ParamName);
            Console.WriteLine(result.Message);
        }
Beispiel #2
0
        public void DestroyDestroysDatabase()
        {
            var connectionInfo = new MockDbConnectionInfo
            {
                ConnectionStringName = "Test1"
            };

            MockDatabaseProvider.Create(connectionInfo);

            MockDatabaseProvider.Destroy(connectionInfo);

            Assert.Throws <ArgumentException>(() => MockDatabaseProvider.Open(connectionInfo));
        }
Beispiel #3
0
        public void Run(IDbConnectionInfo connectionInfo)
        {
            var db = MockDatabaseProvider.Open(connectionInfo) as TestMockDatabase;

            if (db == null)
            {
                throw new ArgumentException("Could not open mock database from supplied connectionInfo", "connectionInfo");
            }

            db.Table.Add(new TestMockDatabase.Row {
                Id = 3, RowName = "Three"
            });
        }
Beispiel #4
0
        public void Run(IDbConnectionInfo connectionInfo)
        {
            var db = MockDatabaseProvider.Open(connectionInfo) as TestMockDatabase;

            if (db == null)
            {
                throw new ArgumentException("Could not open mock database from supplied connectionInfo", "connectionInfo");
            }

            // Schema already defined in TestMockDatabase

            // TODO: Is there a point to this for mock databases?
        }
        public void CreateCreatesDatabase()
        {
            var manager = new MockDbManager
            {
                Description = new DbDescription
                {
                    XmlRoot        = DbDescriptions.Valid,
                    ConnectionInfo = GlobalTest.DbManager1.Description.ConnectionInfo
                }
            };

            manager.Create();

            Assert.That(MockDatabaseProvider.Open(GlobalTest.DbManager1.Description.ConnectionInfo), Is.Not.Null);
        }
        public void DestroyDestroysDatabase()
        {
            var manager = new MockDbManager
            {
                Description = new DbDescription
                {
                    XmlRoot        = DbDescriptions.Valid,
                    ConnectionInfo = GlobalTest.DbManager1.Description.ConnectionInfo
                }
            };

            manager.Create();
            manager.Destroy();

            Assert.That(() => MockDatabaseProvider.Open(GlobalTest.DbManager1.Description.ConnectionInfo),
                        Throws.ArgumentException);
        }
Beispiel #7
0
        public void SubsequentOpenReturnsCreated()
        {
            var connectionInfo = new MockDbConnectionInfo
            {
                ConnectionStringName = "Test1"
            };

            {
                var mockDatabase = MockDatabaseProvider.Create(connectionInfo);
                ((TestMockDatabase)mockDatabase).Table.Add(new TestMockDatabase.Row {
                    Id = 101, RowName = "ThisIsARow"
                });
            }

            {
                var mockDatabase = MockDatabaseProvider.Open(connectionInfo);
                Assert.AreEqual(101, ((TestMockDatabase)mockDatabase).Table[0].Id);
                Assert.AreEqual("ThisIsARow", ((TestMockDatabase)mockDatabase).Table[0].RowName);
            }
        }
Beispiel #8
0
        public void SeedSeedsDatabase()
        {
            var manager = new MockDbManager
            {
                Description = new DbDescription
                {
                    XmlRoot        = DbDescriptions.Valid,
                    ConnectionInfo = GlobalTest.DbManager1.Description.ConnectionInfo
                }
            };

            manager.Create();
            manager.Seed();

            var db = MockDatabaseProvider.Open(GlobalTest.DbManager1.Description.ConnectionInfo) as TestMockDatabase;

            var row = db.Table.SingleOrDefault(r => r.Id == 3);

            Assert.That(row, Is.Not.Null);
        }
Beispiel #9
0
 public void OpenThrowsIfConnectionInfoIsInvalid()
 {
     InvalidConnectionInfoTests(connectionInfo => MockDatabaseProvider.Open(connectionInfo));
 }