public void SaveOneMillionEventsWithLMDBAndDummyPublisher()
        {
            int numberOfEvents = 1000000;
            int serialId       = 0;

            //For some reason, the values higher than 500 MB does not work.

            //TB = 1099511627776
            //GB = 1073741824
            //500MB = 524288000
            //100MB = 104857600

            IEventStoreBuilder builder = new EventStoreBuilder();
            var eventStore             = builder.UseLMDBRepository()
                                         .Configuration(@"c:\temp\lmdbevents", 2, 524288000, new ProtobufEventsSerializer())
                                         .UseCustom(new DummyEventPublisher())
                                         .Build();

            var before = DateTime.Now;

            var tasks = new ConcurrentBag <Task>();

            foreach (int i in Enumerable.Range(0, numberOfEvents))
            {
                tasks.Add(eventStore.Process(new EventTransaction
                {
                    Events = new[] {
                        new Event
                        {
                            AggregateId     = Guid.NewGuid(),
                            SerialId        = serialId++,
                            SerializedEvent = BitConverter.GetBytes(i),
                            EventType       = "A type of event"
                        }
                    }
                }));
            }

            Task.WhenAll(tasks.ToArray()).Wait();

            var after = DateTime.Now;

            var timeInMilliseconds = (after - before).TotalMilliseconds;
            var rate = numberOfEvents / (after - before).TotalSeconds;

            eventStore.Dispose();

            Assert.True(true, string.Format("Added {0} in {1} milliseconds, which is a rate of {2} per second", numberOfEvents, timeInMilliseconds, rate));
        }
        public void ReadOneMillionFromLMDB()
        {
            int numberOfEvents = 1000000;
            int serialId       = 0;

            IEventStoreBuilder builder = new EventStoreBuilder();
            var eventStore             = builder.UseLMDBRepository()
                                         .Configuration(@"c:\temp\lmdbevents", 2, 524288000, new ProtobufEventsSerializer())
                                         .UseCustom(new DummyEventPublisher())
                                         .Build();

            var tasks = new ConcurrentBag <Task>();

            foreach (int i in Enumerable.Range(0, numberOfEvents))
            {
                tasks.Add(eventStore.Process(new EventTransaction
                {
                    Events = new[] {
                        new Event
                        {
                            AggregateId     = Guid.NewGuid(),
                            SerialId        = serialId++,
                            SerializedEvent = BitConverter.GetBytes(i),
                            EventType       = "A type of event"
                        }
                    }
                }));
            }

            Task.WhenAll(tasks.ToArray()).Wait();

            var before = DateTime.Now;

            var x = eventStore.GetAllEvents(0, 1000000);

            var after = DateTime.Now;

            var timeInMilliseconds = (after - before).TotalMilliseconds;
            var rate = numberOfEvents / (after - before).TotalSeconds;

            eventStore.Dispose();

            Assert.True(true, string.Format("Read {0} in {1} milliseconds, which is a rate of {2} per second", numberOfEvents, timeInMilliseconds, rate));
        }
        public void BuildLMDBEventStoreDoesNotThrow()
        {
            IEventStoreBuilder builder = new EventStoreBuilder();

            EventStore es = null;

            es = builder.UseLMDBRepository()
                 .Configuration(@"c:\lmdb", 2, 10485760, new ProtobufEventsSerializer())
                 .UseCustom(new DummyEventPublisher())
                 .Build();

            Assert.NotNull(es);

            //Clean up database
            es.Dispose();


            //Cleaning up disk

            GC.Collect();
            GC.WaitForPendingFinalizers();

            var datafile = Path.Combine(@"c:\lmdb", "data.mdb");

            if (File.Exists(datafile))
            {
                File.Delete(datafile);
            }

            var lockfile = Path.Combine(@"c:\lmdb", "lock.mdb");

            if (File.Exists(lockfile))
            {
                File.Delete(lockfile);
            }
        }