public void CreateCreatesDatabase() { var connectionInfo = new MockDbConnectionInfo { ConnectionStringName = "Test1" }; var mockDatabase = MockDatabaseProvider.Create(connectionInfo); Assert.IsNotNull(mockDatabase); }
public void DestroyDestroysDatabase() { var connectionInfo = new MockDbConnectionInfo { ConnectionStringName = "Test1" }; MockDatabaseProvider.Create(connectionInfo); MockDatabaseProvider.Destroy(connectionInfo); Assert.Throws <ArgumentException>(() => MockDatabaseProvider.Open(connectionInfo)); }
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); }
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); } }
public void CreateThrowsIfConnectionInfoIsInvalid() { InvalidConnectionInfoTests(connectionInfo => MockDatabaseProvider.Create(connectionInfo)); }