Example #1
0
        public async Task ExecuteCommand()
        {
            string container  = "testing";
            string connection = "";
            //var appender = new AzureAsyncAppender(connection, container, new PrefixedDirectory("demo"));
            //await appender.Initialize();

            var appender = new MemoryAppendStoreAsync();

            var es = new EventStoreAsync(appender);

            var dispatcher = new SaySomething(es);

            await dispatcher.GetExecutor(
                new SayCommand
            {
                PersonId  = new PersonId(1),
                Say       = "I am Winter ",
                Timestamp = DateTime.UtcNow
            }).Execute();

            await dispatcher.GetExecutor(
                new SayCommand
            {
                PersonId  = new PersonId(1),
                Say       = "How are you?",
                Timestamp = DateTime.UtcNow
            }).Execute();

            await dispatcher.GetExecutor(
                new SayCommand
            {
                PersonId  = new PersonId(1),
                Say       = "Dunno...",
                Timestamp = DateTime.UtcNow
            }).Execute();

            await dispatcher.GetExecutor(
                new SayCommand
            {
                PersonId  = new PersonId(1),
                Say       = "ok say something more",
                Timestamp = DateTime.UtcNow
            }).Execute();

            await dispatcher.GetExecutor(
                new SayCommand
            {
                PersonId  = new PersonId(1),
                Say       = "NO!",
                Timestamp = DateTime.UtcNow
            }).Execute();

            var events = (await es.ReplayAll()).Events;

            Assert.Equal(5, events.Count);
        }
Example #2
0
        public async Task ReadFileAsEvents()
        {
            var fs = new FileAppendOnlyStoreAsync(new FileAppendOnlyStoreAsync.Options(File)
            {
                MasterStreamName = "mystream_stream"
            });
            var es     = new EventStoreAsync(fs);
            var stream = await es.ReplayAll(0, int.MaxValue);

            Assert.NotEmpty(stream.Events);
        }
        public async Task AppendToEmptyStream()
        {
            var appender = new MemoryAppendStoreAsync();
            var es       = new EventStoreAsync(appender);

            var dispatcher = new TastyDomainDriven.Sample.CommandServices.SaySomething(es);

            await
            dispatcher.GetExecutor(new SayCommand()
            {
                PersonId  = new PersonId(1),
                Say       = "I have something to say",
                Timestamp = DateTime.UtcNow
            }).Execute();

            Assert.Equal(1, (await es.ReplayAll()).Events.Count);
        }
        public async Task AppendToToPublisher()
        {
            var appender = new MemoryAppendStoreAsync();
            var es       = new EventStoreAsync(appender);
            ITableReaderWriter <Saying> table = new MemoryHashTableWriter <Saying>();

            var publisher  = new EventStoreAsyncPublisher(es, new AsyncProjectFromImplementation(new SayingHistoryProjection(table)));
            var dispatcher = new Sample.CommandServices.SaySomething(publisher);

            await
            dispatcher.GetExecutor(new SayCommand()
            {
                PersonId  = new PersonId(1),
                Say       = "I have something to say",
                Timestamp = DateTime.UtcNow
            }).Execute();

            Assert.Equal(1, (await es.ReplayAll()).Events.Count);
            Assert.Equal(1, (await table.GetAll()).Count);
        }