示例#1
0
        public void CreateCreatesDatabase()
        {
            var connectionInfo = new MockDbConnectionInfo
            {
                ConnectionStringName = "Test1"
            };

            var mockDatabase = MockDatabaseProvider.Create(connectionInfo);

            Assert.IsNotNull(mockDatabase);
        }
示例#2
0
        public void DestroyDestroysDatabase()
        {
            var connectionInfo = new MockDbConnectionInfo
            {
                ConnectionStringName = "Test1"
            };

            MockDatabaseProvider.Create(connectionInfo);

            MockDatabaseProvider.Destroy(connectionInfo);

            Assert.Throws <ArgumentException>(() => MockDatabaseProvider.Open(connectionInfo));
        }
示例#3
0
        public void OpenThrowsIfDatabaseNameDoesNotExist()
        {
            var connectionInfo = new MockDbConnectionInfo
            {
                ConnectionStringName = "Test1"
            };

            MockDatabaseProvider.Create(connectionInfo);

            connectionInfo.ConnectionStringName = "Test2";

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

            Assert.AreEqual("connectionInfo", result.ParamName);
            Console.WriteLine(result.Message);
        }
示例#4
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);
            }
        }
示例#5
0
 public void CreateThrowsIfConnectionInfoIsInvalid()
 {
     InvalidConnectionInfoTests(connectionInfo => MockDatabaseProvider.Create(connectionInfo));
 }