Esempio n. 1
0
        public void _Loads_Single_Record_From_Memory()
        {
            if (_transactions.Count() == 0)
            {
                var data = _setup.getSkinnyTransactionSet(_qtyCrapTons);
                _transactions.AddRange(data);
            }

            var idToFind = 5001;
            var trans    = _transactions.First(t => t.TransactionId == idToFind);

            Assert.True(trans != null);
        }
Esempio n. 2
0
        public void MemoryDataExcercises(int qtyRecords)
        {
            // Start from fresh:
            this.DropTransctionTable();
            this.CreateTransctionTable();

            // Load the empty table:
            var transactions = new SQLServerList <Transaction>(_connectionString, _tableName, _tablePkName);

            transactions.Clear();

            var sw = new Stopwatch();

            sw.Start();

            // Insert a bunch of records:
            var data = this.getSkinnyTransactionSet(qtyRecords);

            transactions.AddRange(data);
            sw.Stop();
            this.LogOutput("Wrote", qtyRecords, sw.ElapsedMilliseconds);

            transactions = this.ReadTransactionTable();

            sw.Reset();
            sw.Start();

            // Find a record by arbitrary field (NOT the PK):
            var item = transactions.First(t => t.Identifier == "AA-9000");

            sw.Stop();
            this.LogOutput("Found single by field content", 1, sw.ElapsedMilliseconds);
            this.LogOutput("Found item: " + item.Identifier);


            sw.Reset();
            sw.Start();

            // Query against some criteria:
            var query = from t in transactions where (t.Amount > 100 && t.Amount < 150) select t;

            this.LogOutput("Read queried values from memory", query.Count(), sw.ElapsedMilliseconds);

            Console.WriteLine("Queried Values:");
            foreach (var trans in query)
            {
                this.LogOutput("Id: " + trans.TransactionId + " Comment: " + trans.Comment + " Amount: " + trans.Amount);
            }
            sw.Stop();
            this.LogOutput("Wrote queried values out to console", query.Count(), sw.ElapsedMilliseconds);
        }