예제 #1
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);
        }
예제 #2
0
        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);
        }