public void UsesNewConnectionForEachAdd() { const string xml = "<tag></tag>"; var count = 0; var repo = new DbXmlKeysRepository(() => { count++; return(_postgresTestHelper.ConnectionFactory()); }); repo.Add(new XmlKey { Xml = xml }); repo.Add(new XmlKey { Xml = xml }); Assert.AreEqual(2, count); }
public void AddsElementToTable() { const string xml = "<tag></tag>"; var repo = new DbXmlKeysRepository(_postgresTestHelper.ConnectionFactory); var insertedKey = repo.Add(new XmlKey { Xml = xml }); var actualKey = _postgresTestHelper.Connection.QueryFirst <XmlKey>( @"Select * from ""XmlKeys"" where Id = @Id", new { Id = insertedKey }); Assert.AreEqual(xml, actualKey.Xml); }