public void _Inserts_Single_Typed_Record() { _setup.CheckSetUp(); var newRecord = new Transaction() { Amount = 100, Comment = "I Overspent!", Identifier = "XXX" }; var model = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn); var inserted = model.Insert(newRecord); Assert.True(newRecord.TransactionId > 0); }
public void _Inserts_Single_Anonymous_Record() { _setup.CheckSetUp(); dynamic newRecord = new { Amount = 100, Comment = "I Anonymously Overspent!", Identifier = "YYZ" // Bah da-bah-bah-bah da bah-bah-bah-bah }; var model = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn); var inserted = model.Insert(newRecord); Assert.True(inserted.TransactionId > 0); }
public void _Deletes_Typed_Record() { _setup.CheckSetUp(); var model = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn); var newRecord = new Transaction() { Amount = 100, Comment = "I Overspent!", Identifier = "XXX" }; model.Insert(newRecord); int recordPk = newRecord.TransactionId; newRecord = model.Find <Transaction>(recordPk); int deleted = model.Delete(newRecord.TransactionId); newRecord = model.Find <Transaction>(recordPk); Assert.True(deleted > 0 && newRecord == null); }
public void _Deletes_Anonymous_Record() { _setup.CheckSetUp(); var model = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn); var newRecord = new { Amount = 100, Comment = "I Anonymously Overspent!", Identifier = "YYZ" // Bah da-bah-bah-bah da bah-bah-bah-bah }; //HACK - you can't interrogate the new record like you were doing... var result = model.Insert(newRecord); //WTF WHY IS THIS COMING BACK AS A DECIMAL var recordPk = result.TransactionId; // Retrieve the updated item from the Db: var recordToDelete = model.Find <Transaction>(recordPk); int deleted = model.Delete(recordToDelete.TransactionId); recordToDelete = model.Find <Transaction>(recordPk); Assert.True(deleted > 0 && recordToDelete == null); }
public void _Updates_Typed_Record() { _setup.CheckSetUp(); var model = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn); var newRecord = new Transaction() { Amount = 100, Comment = "I Overspent!", Identifier = "XXX" }; // Dump the new record in as an UPDATE: model.Insert(newRecord); int recordPk = newRecord.TransactionId; string newValue = "I changed it!"; newRecord.Identifier = newValue; int updated = model.Update(newRecord); newRecord = model.Find <Transaction>(recordPk); Assert.True(updated > 0 && newRecord.Identifier == newValue); }
public void _Updates_Anonymous_Record() { _setup.CheckSetUp(); var model = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn); var newRecord = new Transaction { Amount = 100, Comment = "I Anonymously Overspent!", Identifier = "YYZ" // Bah da-bah-bah-bah da bah-bah-bah-bah da da . . . }; var result = model.Insert(newRecord); int recordPk = result.TransactionId; var updateThis = new { Identifier = "I changed it!" }; int updated = model.Update(updateThis, recordPk); // Retrieve the updated item from the Db: var updatedRecord = model.Find <Transaction>(recordPk); Assert.True(updated > 0 && updatedRecord.Identifier == updateThis.Identifier); }