Res.Core.StorageBuffering.EventStorageReader.Start C# (CSharp) Method

Start() public method

public Start ( CancellationToken token ) : Task
token System.Threading.CancellationToken
return Task
        public Task Start(CancellationToken token)
        {
            return Task.Factory.StartNew(() => run(token), token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
        }

Usage Example

Ejemplo n.º 1
0
        public void should_be_able_to_fetch_a_particular_event()
        {
            var storage = new InMemoryEventStorage();

            var now = new DateTime(2013, 1, 1);
            var createEventsDetails = new Dictionary<Guid, CreateEventsMetaData>();
            var j = 0;
            for (var i = 1; i <= 1; i++)
            {
                createEventsDetails.Add(Guid.NewGuid(), new CreateEventsMetaData(1, "foo", "stream", new[] { now.AddMilliseconds(++j) }));
            }
            var commitDetails = new EventsInjector(storage).InsertEvents(createEventsDetails);
            var reader = new EventStorageReader(10, TimeSpan.FromMinutes(5), storage);
            var eventTask = reader.Fetch(new FetchEventRequest(commitDetails[0].Events[0].EventId, "foo", "stream"));
            reader.Start(_token.Token);
            var @event = eventTask.Result;
            var expecetdEvent = commitDetails[0].Events[0];

            Assert.That(@event, !Is.Null, "No event is fetched");
            Assert.That(@event.EventId, Is.EqualTo(expecetdEvent.EventId), "This is not the exepected event from the fetch opeartion");
            Assert.That(@event.Sequence, Is.EqualTo(expecetdEvent.Sequence), "This is not the exepected sequence of the event from the fetch opeartion");
            Assert.That(@event.Timestamp, Is.EqualTo(expecetdEvent.Timestamp), "This is not the exepected sequence of the event from the fetch opeartion");
            Assert.That(@event.TypeKey, Is.EqualTo(expecetdEvent.TypeKey), "This is not the exepected type of the event from the fetch opeartion");
        }
All Usage Examples Of Res.Core.StorageBuffering.EventStorageReader::Start