Ejemplo n.º 1
0
        public void SkipListOnUpgrade()
        {
            var manager = new EventStoreManager();

            manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(UserEventList), "UserEvent"));
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var userA    = new User {
                Name = "A", Age = 1
            };
            var userB = new User {
                Name = "B", Age = 2
            };
            var userEvent = new UserEventList {
                Id = 10, List = new List <User> {
                    userA, userB, userA
                }
            };

            appender.Store(null, new object[] { userEvent });

            manager = new EventStoreManager();
            manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(UserEvent), "UserEvent"));
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            var readUserEvent = (UserEvent)eventObserver.Events[0][0];

            Assert.Equal(10, readUserEvent.Id);
            Assert.Null(readUserEvent.User1);
        }
Ejemplo n.º 2
0
        public void CustomEventIsReadFromSecondSplit()
        {
            var manager = new EventStoreManager();

            manager.CompressionStrategy = new NoCompressionStrategy();
            manager.SetNewTypeNameMapper(new SimplePersonTypeMapper());
            var appender = manager.AppendToStore(new MemoryEventFileStorage(4096, 4096));
            var first    = appender.CurrentFileStorage;
            var user     = new User {
                Name = "A", Age = 1
            };

            while (appender.CurrentFileStorage == first)
            {
                appender.Store(null, new object[] { user });
            }
            var second = appender.CurrentFileStorage;

            manager = new EventStoreManager();
            manager.CompressionStrategy = new NoCompressionStrategy();
            manager.SetNewTypeNameMapper(new SimplePersonTypeMapper());
            var reader        = manager.OpenReadOnlyStore(second);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            Assert.Equal(new[] { new object[] { user } }, eventObserver.Events);
        }
Ejemplo n.º 3
0
        static object PassThroughEventStorage(object @event, ITypeNameMapper mapper)
        {
            var options = TypeSerializersOptions.Default;

            options.SymmetricCipher = new AesGcmSymmetricCipher(new byte[]
            {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
                28, 29, 30, 31
            });
            var manager  = new EventStoreManager(options);
            var storage  = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(storage);
            var events   = new[]
            {
                @event
            };

            appender.Store(null, events);
            manager = new EventStoreManager(options);
            manager.SetNewTypeNameMapper(mapper);
            var eventObserver = new EventStoreTest.StoringEventObserver();

            manager.OpenReadOnlyStore(storage).ReadFromStartToEnd(eventObserver);
            return(eventObserver.Events[0][0]);
        }
Ejemplo n.º 4
0
        public void SupportsList()
        {
            var manager  = new EventStoreManager();
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var userA    = new User {
                Name = "A", Age = 1
            };
            var userB = new User {
                Name = "B", Age = 2
            };
            var userEvent = new UserEventList {
                Id = 10, List = new List <User> {
                    userA, userB, userA
                }
            };

            appender.Store(null, new object[] { userEvent });

            manager = new EventStoreManager();
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            var readUserEvent = (UserEventList)eventObserver.Events[0][0];

            Assert.Equal(readUserEvent, userEvent);
        }
Ejemplo n.º 5
0
        public void Run()
        {
            var manager = new EventStoreManager();

            //manager.CompressionStrategy = new NoCompressionStrategy();
            using (var stream = new FileStream("0.event", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1))
            {
                var file = new StreamEventFileStorage(stream);
                _writeStore = manager.AppendToStore(file);
                var consumerTask = Task.Factory.StartNew(EventConsumer, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler);
                _sw.Start();
                var tasks = new Task[ParallelTasks];
                Parallel.For(0, tasks.Length, i =>
                {
                    tasks[i] = PublishSampleEvents(RepetitionCount);
                });
                Task.WaitAll(tasks);
                _bc.CompleteAdding();
                consumerTask.Wait();
                _sw.Stop();
                Console.WriteLine("Write {0}ms events per second:{1:f0} total len:{2}", _sw.ElapsedMilliseconds, tasks.Length * RepetitionCount / _sw.Elapsed.TotalSeconds, stream.Length);
                _sw.Restart();
                var allObserverCounter = new AllObserverCounter();
                manager.OpenReadOnlyStore(file).ReadFromStartToEnd(allObserverCounter);
                _sw.Stop();
                Console.WriteLine("Read {0}ms events per second:{1:f0} events:{2}", _sw.ElapsedMilliseconds, allObserverCounter.Count / _sw.Elapsed.TotalSeconds, allObserverCounter.Count);
            }
        }
Ejemplo n.º 6
0
        public void CanReadLongerEventsFromIncompleteFile()
        {
            var manager = new EventStoreManager();

            manager.CompressionStrategy = new NoCompressionStrategy();
            var file1    = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file1);

            appender.Store(null, new object[] { new byte[8000] });
            var file2 = new MemoryEventFileStorage();
            var buf   = ByteBuffer.NewSync(new byte[4096]);

            file1.Read(buf, 0);
            file2.Write(buf, 0);
            var reader = manager.OpenReadOnlyStore(file2);

            reader.ReadFromStartToEnd(new SkippingEventObserver());
            Assert.False(reader.IsKnownAsCorrupted());
            Assert.False(reader.IsKnownAsAppendable());
            Assert.False(reader.IsKnownAsFinished());
            buf = ByteBuffer.NewSync(new byte[4096]);
            file1.Read(buf, 4096);
            file2.Write(buf, 4096);
            reader.ReadToEnd(new SkippingEventObserver());
            Assert.False(reader.IsKnownAsCorrupted());
            Assert.True(reader.IsKnownAsAppendable());
            Assert.False(reader.IsKnownAsFinished());
        }
Ejemplo n.º 7
0
        public void TypeMapperCanForceSkipEvents()
        {
            var manager = new EventStoreManager();

            manager.SetNewTypeNameMapper(new FullNameTypeMapper());
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var user     = new User {
                Name = "ABC", Age = 88
            };
            var userEvent = new UserEvent {
                Id = 10, User1 = user, User2 = user
            };
            var userEventMore = new UserEventMore {
                Id = 11, User1 = user, User2 = user
            };

            appender.Store(null, new object[] { userEvent, userEventMore });

            manager = new EventStoreManager();
            manager.SetNewTypeNameMapper(new SelectiveTypeMapper("BTDBTest.EventStoreTest+UserEvent"));
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new SimpleEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            Assert.Single(eventObserver.Events[0]);
            var readUserEvent = (UserEventMore)eventObserver.Events[0][0];

            Assert.Same(readUserEvent.User1, readUserEvent.User2);
        }
Ejemplo n.º 8
0
        public async Task GetAllEventsByAggregateId_AsExpected()
        {
            try
            {
                DeleteAll();
                new Bootstrapper()
                .UseEFCoreAsEventStore(
                    new EFEventStoreOptions(c =>
                                            c.UseSqlite("Filename=Events_Test_Base.db")))
                .Bootstrapp();
                var agg = new SampleAgg();
                agg.SimulateWork();
                await agg.PublishDomainEventsAsync();

                using (var ctx = GetContext())
                {
                    ctx.Set <Event>().Should().HaveCount(2);
                }

                var collection = await new EFEventStore(GetOptions()).GetAllEventsByAggregateId <SampleAgg, Guid>(agg.Id).ToListAsync();
                collection.Should().HaveCount(2);

                collection.Any(e => e.GetType() == typeof(AggCreated)).Should().BeTrue();
                collection.Any(e => e.GetType() == typeof(AggDeleted)).Should().BeTrue();
                collection.All(e => e.AggregateId is Guid guidId && guidId == agg.Id).Should().BeTrue();
                collection[0].Should().BeOfType <AggCreated>();
                collection.Skip(1).First().Should().BeOfType <AggDeleted>();
            }
            finally
            {
                EventStoreManager.Deactivate();
                DeleteAll();
            }
        }
Ejemplo n.º 9
0
        public void UpgradeToLessObjectProperties()
        {
            var manager = new EventStoreManager();

            manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(UserEvent), "UserEvent"));
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var user     = new User {
                Name = "A", Age = 1
            };
            var userEvent = new UserEvent {
                Id = 10, User1 = user, User2 = user
            };

            appender.Store(null, new object[] { userEvent, new User {
                                                    Name = "B"
                                                } });

            manager = new EventStoreManager();
            manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(UserEventLess), "UserEvent"));
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            var readUserEvent = (UserEventLess)eventObserver.Events[0][0];

            Assert.Equal("A", readUserEvent.User2.Name);
            Assert.Equal(10, readUserEvent.Id);
            Assert.Equal("B", ((User)eventObserver.Events[0][1]).Name);
        }
Ejemplo n.º 10
0
        public void CanStoreNullable()
        {
            var testEvent = new EventWithNullable
            {
                EventId           = 1,
                NullableInt       = 42,
                ListWithNullables = new List <int?> {
                    4, new int?()
                },
                DictionaryWithNullables = new Dictionary <int?, bool?> {
                    { 1, true }, { 2, new bool?() }
                }
            };

            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.Store(null, new object[] { testEvent });

            var eventObserver = new StoringEventObserver();

            appender.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            var ev = eventObserver.Events[0][0] as EventWithNullable;

            Assert.Equal(42, ev.NullableInt.Value);
            Assert.False(ev.NullableEmpty.HasValue);
            Assert.Equal(2, ev.ListWithNullables.Count);
            Assert.Equal(4, ev.ListWithNullables[0].Value);
            Assert.False(ev.ListWithNullables[1].HasValue);
            Assert.Equal(2, ev.DictionaryWithNullables.Count);
            Assert.True(ev.DictionaryWithNullables[1]);
            Assert.False(ev.DictionaryWithNullables[2].HasValue);
        }
Ejemplo n.º 11
0
        public void CanStopReadBatchesAfterFirst()
        {
            var manager  = new EventStoreManager();
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var metadata = new User {
                Name = "A", Age = 1
            };
            var events = new object[]
            {
                new User {
                    Name = "B", Age = 2
                },
                new User {
                    Name = "C", Age = 3
                }
            };

            appender.Store(metadata, events);
            appender.Store(metadata, events);

            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserverWithStop();

            reader.ReadFromStartToEnd(eventObserver);
            Assert.False(reader.IsKnownAsCorrupted());
            Assert.False(reader.IsKnownAsFinished());
            Assert.False(reader.IsKnownAsAppendable());
            Assert.Equal(new List <object> {
                metadata
            }, eventObserver.Metadata);
            Assert.Equal(new[] { events }, eventObserver.Events);
        }
Ejemplo n.º 12
0
        public void SupportsDictionary()
        {
            var manager  = new EventStoreManager();
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var userA    = new User {
                Name = "A", Age = 1
            };
            var userB = new User {
                Name = "B", Age = 2
            };
            var userEvent = new UserEventDictionary {
                Id = 10, Dict = new Dictionary <string, User> {
                    { "A", userA }, { "B", userB }
                }
            };

            appender.Store(null, new object[] { userEvent });

            manager = new EventStoreManager();
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            var readUserEvent = (UserEventDictionary)eventObserver.Events[0][0];

            Assert.Equal(readUserEvent, userEvent);
        }
Ejemplo n.º 13
0
        public void SurvivesListVsIList()
        {
            var manager = new EventStoreManager();

            manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(SomethingWithoutList), "Some"));
            var file     = new MemoryEventFileStorage();
            var file2    = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);

            var ev = new SomethingWithList();

            appender.Store(null, new object[] { ev });
            var ev2 = new SomethingWithNestedIList
            {
                B = new Dictionary <ulong, IList <string> > {
                    { 1, new List <string> {
                          "a1"
                      } }
                }
            };

            appender.Store(null, new object[] { ev2 });
            var appender2 = manager.AppendToStore(file);

            appender2.Store(null, new object[] { ev2 });
            manager = new EventStoreManager();
            manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(SomethingWithList), "Some"));
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            reader = manager.OpenReadOnlyStore(file2);
            reader.ReadFromStartToEnd(eventObserver);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Use MongoDb with a one or multiple server urls.
        /// Multiples urls are usefull when a replica set has been created.
        /// </summary>
        /// <param name="bootstrapper">Bootstrapper instance.</param>
        /// <param name="options">Options to bootstrap MongoDb as Event Store.</param>
        /// <returns>Bootstrapper instance.</returns>
        public static Bootstrapper UseMongoDbAsEventStore(this Bootstrapper bootstrapper, MongoEventStoreOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var service = new MongoDbEventStoreBootstrappService
                              (ctx =>
            {
                BsonSerializer.RegisterSerializer(typeof(Type), new TypeSerializer());
                BsonSerializer.RegisterSerializer(typeof(Guid), new GuidSerializer());
                BsonSerializer.RegisterSerializer(typeof(object), new ObjectSerializer());
                EventStoreManager.Options = options;
                if (options.SnapshotBehaviorProvider != null)
                {
                    if (ctx.IsServiceRegistered(BootstrapperServiceType.IoC))
                    {
                        bootstrapper.AddIoCRegistration(new InstanceTypeRegistration(options.SnapshotBehaviorProvider, typeof(ISnapshotBehaviorProvider)));
                        bootstrapper.AddIoCRegistration(new FactoryRegistration(
                                                            () => new MongoDbEventStore(options.SnapshotBehaviorProvider, options.SnapshotEventsArchiveBehavior),
                                                            typeof(MongoDbEventStore), typeof(IWriteEventStore)));
                    }
                }
                EventStoreManager.Activate();
            }
                              );

            bootstrapper.AddService(service);
            return(bootstrapper);
        }
Ejemplo n.º 15
0
        public void StoreListThenArray()
        {
            var a = new EventStoreManager().AppendToStore(
                new MemoryEventFileStorage());

            a.Store(null, new[] { new List <bool>() });
            a.Store(null, new[] { new[] { true } });
            a.Store(null, new[] { new HashSet <bool>() });
        }
Ejemplo n.º 16
0
        public void CanFinalizeEventStore()
        {
            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.FinalizeStore();
            Assert.False(appender.IsKnownAsAppendable());
            Assert.False(appender.IsKnownAsCorrupted());
            Assert.True(appender.IsKnownAsFinished());
        }
        public void EventStoreManager_CanBeCreated_IsCreated()
        {
            Mock <Func <String, IEventStoreContext> > contextResolver = new Mock <Func <String, IEventStoreContext> >();
            Mock <Func <IConfigurationRepository> >   configurationRepositoryResolver = new Mock <Func <IConfigurationRepository> >();
            Mock <IOptions <EventStoreSettings> >     eventStoreSettings = new Mock <IOptions <EventStoreSettings> >();

            EventStoreManager manager = new EventStoreManager(contextResolver.Object, configurationRepositoryResolver.Object, eventStoreSettings.Object);

            manager.ShouldNotBeNull();
        }
Ejemplo n.º 18
0
        public void CreatesNewFileWhenOldOneIsFull()
        {
            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.Store(null, new object[] { 1 });
            appender.ReadFromStartToEnd(new SkippingEventObserver());
            appender.FinalizeStore();
            Assert.False(appender.IsKnownAsAppendable());
            Assert.False(appender.IsKnownAsCorrupted());
            Assert.True(appender.IsKnownAsFinished());
        }
Ejemplo n.º 19
0
 public void CanFinalizeEventStoreOnEverySectorPosition()
 {
     for (int i = 4000; i < 4600; i++)
     {
         var manager = new EventStoreManager();
         manager.CompressionStrategy = new NoCompressionStrategy();
         var file1    = new MemoryEventFileStorage(4096, 8192);
         var appender = manager.AppendToStore(file1);
         appender.Store(null, new object[] { new byte[i] });
         appender.Store(null, new object[] { new byte[7000] });
     }
 }
        private SalesforceAnalyticsManager(Account account, string communityId)
        {
            var deviceAppAttributes = BuildDeviceAppAttributes();

            analyticsManager = new AnalyticsManager(account.GetCommunityLevelFileNameSuffix(), deviceAppAttributes,
                                                    PincodeManager.RetrievePinCodeHash());
            eventStoreManager = (EventStoreManager)analyticsManager.GetEventStoreManager();
            remotes           = new Dictionary <ITransform, IAnalyticsPublisher>();
            var transformer = new AiltnTransform();
            var publisher   = new AiltnPublisher();

            remotes.Add(transformer, publisher);
        }
Ejemplo n.º 21
0
        public void WhenReadOnlyStoreIsCreatedFromNewEventStoreManagerThenItShouldNotLeakMemory()
        {
            var storage = new MemoryEventFileStorage();

            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(storage);
            var metadata = new User {
                Name = "A", Age = 1
            };
            var events = new object[]
            {
                new User {
                    Name = "B", Age = 2
                },
                new User {
                    Name = "C", Age = 3
                }
            };

            appender.Store(metadata, events);
            appender.FinalizeStore();

            manager = new EventStoreManager();
            var  eventObserver  = new StoringEventObserver();
            long baselineMemory = 0;

            for (int i = 0; i <= 10000; i++)
            {
                var reader = manager.OpenReadOnlyStore(storage);
                reader.ReadToEnd(eventObserver);

                Assert.Single(eventObserver.Events);
                eventObserver.Events.Clear();
                eventObserver.Metadata.Clear();

                if (i == 10)
                {
                    GC.Collect(2);
                    GC.WaitForPendingFinalizers();
                    GC.Collect(2);
                    baselineMemory = GC.GetTotalMemory(false);
                }
            }

            GC.Collect(2);
            GC.WaitForPendingFinalizers();
            GC.Collect(2);
            Assert.InRange(GC.GetTotalMemory(false), 0, baselineMemory * 3F);
        }
Ejemplo n.º 22
0
        public void UseArrayForStoreIList()
        {
            var manager  = new EventStoreManager();
            var file     = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(file);
            var e        = new UsersIList {
                Users = new[] { new User {
                                    Name = "A"
                                }, new User {
                                    Name = "B"
                                } }
            };

            appender.Store(null, new object[] { e });
        }
Ejemplo n.º 23
0
        public void MoreComplexRepeatedAppendingAndReading()
        {
            var manager = new EventStoreManager();

            for (var i = 490; i < 520; i += 2)
            {
                var file     = new MemoryEventFileStorage();
                var appender = manager.AppendToStore(file);
                appender.Store(null, new object[] { new byte[i] });
                var eventObserver = new StoringEventObserver();
                appender.ReadFromStartToEnd(eventObserver);
                appender.Store(null, new object[] { new byte[i] });
                appender.ReadFromStartToEnd(eventObserver);
            }
        }
Ejemplo n.º 24
0
        public void CannotStoreStruct()
        {
            var testEvent = new EventWithStruct
            {
                EventId   = 1,
                Structure = new Structure()
            };

            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            var e = Assert.Throws <BTDBException>(() => appender.Store(null, new object[] { testEvent }));

            Assert.Contains("Unsupported", e.Message);
        }
Ejemplo n.º 25
0
        public void CanWriteEventWithIndexer()
        {
            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.Store(null, new object[] { new SimpleWithIndexer {
                                                    EvenName = "e", OddName = "o"
                                                } });
            var eventObserver = new StoringEventObserver();

            appender.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            var ev = eventObserver.Events[0][0] as SimpleWithIndexer;

            Assert.Equal("o", ev[11]);
        }
Ejemplo n.º 26
0
        public void CanWriteSimpleEvent()
        {
            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.Store(null, new object[] { 1 });
            var eventObserver = new StoringEventObserver();

            appender.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            Assert.Equal(new[] { new object[] { 1 } }, eventObserver.Events);
            Assert.True(appender.IsKnownAsAppendable());
            Assert.False(appender.IsKnownAsCorrupted());
            Assert.False(appender.IsKnownAsFinished());
            Assert.Equal(10ul, appender.KnownAppendablePosition());
        }
Ejemplo n.º 27
0
        public void SupportPureArray()
        {
            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.Store(null, new object[] { new PureArray {
                                                    A = new[] { "A", "B" }, B = new[] { 42, 7 }
                                                } });
            var eventObserver = new StoringEventObserver();

            appender.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            var ev = eventObserver.Events[0][0] as PureArray;

            Assert.Equal(ev.A, new[] { "A", "B" });
            Assert.Equal(ev.B, new[] { 42, 7 });
        }
Ejemplo n.º 28
0
        static object PassThroughEventStorage(object @event, ITypeNameMapper mapper)
        {
            var manager  = new EventStoreManager();
            var storage  = new MemoryEventFileStorage();
            var appender = manager.AppendToStore(storage);
            var events   = new[]
            {
                @event
            };

            appender.Store(null, events);
            manager = new EventStoreManager();
            manager.SetNewTypeNameMapper(mapper);
            var eventObserver = new EventStoreTest.StoringEventObserver();

            manager.OpenReadOnlyStore(storage).ReadFromStartToEnd(eventObserver);
            return(eventObserver.Events[0][0]);
        }
Ejemplo n.º 29
0
        public void CompressionShortensData()
        {
            var manager          = new EventStoreManager();
            var file             = new MemoryEventFileStorage();
            var appender         = manager.AppendToStore(file);
            var compressibleData = new byte[20000];

            appender.Store(null, new object[] { compressibleData });
            Assert.True(2000 > appender.KnownAppendablePosition());

            manager = new EventStoreManager();
            var reader        = manager.OpenReadOnlyStore(file);
            var eventObserver = new StoringEventObserver();

            reader.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            Assert.Equal(new[] { new object[] { compressibleData } }, eventObserver.Events);
        }
Ejemplo n.º 30
0
        public void SupportStrangeVisibilities()
        {
            var manager  = new EventStoreManager();
            var appender = manager.AppendToStore(new MemoryEventFileStorage());

            appender.Store(null, new object[] { new StrangeVisibilities {
                                                    A = "a", C = "c", D = "d"
                                                } });
            var eventObserver = new StoringEventObserver();

            appender.ReadFromStartToEnd(eventObserver);
            Assert.Equal(new object[] { null }, eventObserver.Metadata);
            var ev = eventObserver.Events[0][0] as StrangeVisibilities;

            Assert.Equal("a", ev.A);
            Assert.Null(ev.B);
            Assert.Equal("c", ev.C);
        }