Beispiel #1
0
        public void CanExecuteReaderFromDbCommand()
        {
            using (TestResourceFile dbFile = new TestResourceFile(this, "Datastore.sdf"))
            {
                using (SmartClientDatabase database = DatabaseFactory.CreateDatabase() as SmartClientDatabase)
                {
                    string    queryString  = @"select * from TestTable";
                    DbCommand queryCommand = new SqlCeCommand();
                    queryCommand.CommandText = queryString;

                    string accumulator = "";
                    using (IDataReader reader = database.ExecuteReader(queryCommand))
                    {
                        while (reader.Read())
                        {
                            accumulator += ((string)reader["TestColumn2"]).Trim();
                        }
                    }

                    Assert.AreEqual("UnoDosTresCuatro", accumulator);
                }
            }
        }
Beispiel #2
0
        public void CanGetRequestsIteratorByPrice()
        {
            using (SmartClientDatabase database = GetDatabase())
            {
                IRequestQueue queue = new DatabaseRequestQueue(database, "Requests");

                Assert.AreEqual(0, queue.GetCount());

                Request request1 = CreateRequest();
                request1.Behavior.Stamps = 8;

                Request request2 = CreateRequest();
                request2.Behavior.Stamps = 3;

                Request request3 = CreateRequest();
                request3.Behavior.Stamps = 5;

                queue.Enqueue(request1);
                queue.Enqueue(request2);
                queue.Enqueue(request3);

                Assert.AreEqual(3, queue.GetCount());

                List <Request> list = new List <Request>();

                foreach (Request req in queue.GetRequests(5))
                {
                    list.Add(req);
                    queue.Remove(req);
                }

                Assert.AreEqual(2, list.Count);
                Assert.IsTrue(AreEqual(request1, list[0]));
                Assert.IsTrue(AreEqual(request3, list[1]));
                Assert.AreEqual(1, queue.GetCount());
            }
        }
Beispiel #3
0
        public void RequestsIteratorIsFifo()
        {
            using (SmartClientDatabase database = GetDatabase())
            {
                IRequestQueue queue = new DatabaseRequestQueue(database, "Requests");

                Assert.AreEqual(0, queue.GetCount());

                Request request1 = CreateRequest();
                Request request2 = CreateRequest();
                Request request3 = CreateRequest();
                Request request4 = CreateRequest();

                queue.Enqueue(request1);
                queue.Enqueue(request2);
                queue.Enqueue(request3);
                queue.Enqueue(request4);

                Assert.AreEqual(4, queue.GetCount());

                List <Request> list = new List <Request>();

                foreach (Request req in queue.GetRequests())
                {
                    list.Add(req);
                    queue.Remove(req);
                }

                Assert.AreEqual(4, list.Count);
                Assert.IsTrue(AreEqual(request1, list[0]));
                Assert.IsTrue(AreEqual(request2, list[1]));
                Assert.IsTrue(AreEqual(request3, list[2]));
                Assert.IsTrue(AreEqual(request4, list[3]));
                Assert.AreEqual(0, queue.GetCount());
            }
        }