Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            /* Can use any RavenDb implementation
             * EmbeddableDocumentStore,
             * RavenDbDocumentStore,
             * DocumentStore
             */
            var ravenDbdocumentStore = new DocumentStore
            {
                Url             = "http://localhost:8080",
                DefaultDatabase = "Customers",
                //ConnectionStringName = "RavenDBDatabaseConnection"
            };
            var repository = new RavenDBcustomerRepository <Customer>(ravenDbdocumentStore);
            var queue      = new PersistenceCustomersQueue <Customer>(repository);
            var server     = new Server <Customer>();
            var barber     = new SleepingBarber <Customer>(queue, server);

            barber.CustomerServed += CustomerServed;
            barber.GoingToSleep   += BarberWentToSleep;
            for (int i = 0; i < 50; i++)
            {
                var name = $"Customer{i}";
                queue.Enqueue(new Customer {
                    Id = name, Name = name, DateCreate = DateTime.Now
                });
                Console.WriteLine($"{i} was added to database");
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void Enqueue_Dequeue_Add_Customer_To_Queue_And_Retrieves_Accordingly()
        {
            var customer1 = new CustomerForTest();
            var customer2 = new CustomerForTest();

            _customersQueue.Enqueue(customer1);
            _customersQueue.Enqueue(customer2);

            Assert.That(_customersQueue.Dequeue(), Is.EqualTo(customer1));
            Assert.That(_customersQueue.Dequeue(), Is.EqualTo(customer2));
        }