public Task WriteStreamAsyncSourceCanNotBeNull()
        {
            var sut =
                new EventSourceWriter(
                    _fixture.Connection,
                    new EventSourceWriterConfiguration(StreamNameConversions.PassThru,
                                                       new EventSourceChangesetTranslator(type => type.Name, new JsonSerializerSettings()))
                    );

            return
                (Assert.ThrowsAsync <ArgumentNullException>(() =>
                                                            sut.WriteStreamAsync(_fixture.NextStreamName(), null, Guid.Empty, Guid.Empty)));
        }
        public async Task CanReadUsingReaderWhatWasWrittenUsingWriter()
        {
            var stream = _fixture.NextStreamName();

            var random = new Random();
            var value1 = random.Next();
            var value2 = random.Next();

            // write
            var changes = new object[]
            {
                new Event1 {
                    Value = value1
                },
                new Event2 {
                    Value = value2
                }
            };
            var writable = new Entity(changes);
            var writer   = new EventSourceWriter(
                _fixture.Connection,
                new EventSourceWriterConfiguration(
                    StreamNameConversions.PassThru,
                    new EventSourceChangesetTranslator(type => type.FullName, new JsonSerializerSettings())));
            await writer.WriteStreamAsync(stream, writable, Guid.NewGuid(), Guid.NewGuid());

            //read
            var reader = new EventSourceReader(
                () => new Entity(),
                _fixture.Connection,
                new EventSourceReaderConfiguration(
                    StreamNameConversions.PassThru,
                    () => new StreamEventsSliceTranslator(
                        name => Type.GetType(name, true),
                        new JsonSerializerSettings()),
                    new SliceSize(1)));
            var result = await reader.ReadStreamAsync(stream);

            Assert.Equal(ReadResultState.Found, result.State);
            var readable = Assert.IsAssignableFrom <Entity>(result.Value);

            Assert.Equal(value1, readable.Value1);
            Assert.Equal(value2, readable.Value2);
        }
Esempio n. 3
0
        public GroupRepository(IEventStoreConnection connection, EventSourceReaderConfiguration readerConfiguration, EventSourceWriterConfiguration writerConfiguration)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (readerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(readerConfiguration));
            }
            if (writerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(writerConfiguration));
            }

            _reader = new EventSourceReader(
                Group.Factory,
                connection,
                readerConfiguration);
            _writer = new EventSourceWriter(
                connection,
                writerConfiguration);
        }
Esempio n. 4
0
 public SimpleFlowController(EventSourceWriter<SimpleInput> writer)
 {
     _writer = writer;
 }