コード例 #1
0
        protected override void SetUp()
        {
            base.SetUp();

            _readCallback = new EnvelopeCallback <ClientMessage.ReadEventCompleted>();

            _eventId = Guid.NewGuid();

            _eventData       = Encoding.UTF8.GetBytes("test data");
            _eventMetadata   = Encoding.UTF8.GetBytes("test metadata");
            _eventStreamId   = "test-stream";
            _eventType       = "someType";
            _expectedVersion = -2;

            _writeCallback = new EnvelopeCallback <ClientMessage.WriteEventsCompleted>();
            Publish(new ClientMessage.WriteEvents(Guid.NewGuid(),
                                                  new SendToThisEnvelope(_writeCallback),
                                                  _eventStreamId,
                                                  _expectedVersion,
                                                  new Event(_eventId, _eventType, false, _eventData, _eventMetadata)));

            _writeCallback.Wait();

            Publish(new ClientMessage.ReadEvent(Guid.NewGuid(), new SendToThisEnvelope(_readCallback), _eventStreamId, 1, false));
        }
コード例 #2
0
        protected virtual void SetUp()
        {
            var dbPath = Path.Combine(Path.GetTempPath(), "EventStoreTests", Guid.NewGuid().ToString());

            Directory.CreateDirectory(dbPath);

            var chunkSize     = 256 * 1024 * 1024;
            var chunksToCache = 2;


            if (Runtime.IsMono)
            {
                _writerChk = new FileCheckpoint(Path.Combine(dbPath, Checkpoint.Writer + ".chk"), Checkpoint.Writer, cached: true);
                _chaserChk = new FileCheckpoint(Path.Combine(dbPath, Checkpoint.Chaser + ".chk"), Checkpoint.Chaser, cached: true);
            }
            else
            {
                _writerChk = new MemoryMappedFileCheckpoint(Path.Combine(dbPath, Checkpoint.Writer + ".chk"), Checkpoint.Writer, cached: true);
                _chaserChk = new MemoryMappedFileCheckpoint(Path.Combine(dbPath, Checkpoint.Chaser + ".chk"), Checkpoint.Chaser, cached: true);
            }

            var nodeConfig = new TFChunkDbConfig(dbPath,
                                                 new VersionedPatternFileNamingStrategy(dbPath, "chunk-"),
                                                 chunkSize,
                                                 chunksToCache,
                                                 _writerChk,
                                                 new[] { _chaserChk });

            var settings = new SingleVNodeSettings(new IPEndPoint(IPAddress.Loopback, 1111),
                                                   new IPEndPoint(IPAddress.Loopback, 2111),
                                                   new[] { new IPEndPoint(IPAddress.Loopback, 2111).ToHttpUrl() });
            var appsets = new SingleVNodeAppSettings(TimeSpan.FromDays(1));

            _db = new TFChunkDb(nodeConfig);

            _vNode = new SingleVNode(_db, settings, appsets);


            var startCallback = new EnvelopeCallback <SystemMessage.SystemStart>();

            _vNode.Bus.Subscribe <SystemMessage.SystemStart>(startCallback);

            _vNode.Start();
            startCallback.Wait();
        }
コード例 #3
0
        protected virtual void TearDown()
        {
            try
            {
                var shutdownCallback = new EnvelopeCallback <SystemMessage.BecomeShutdown>();
                _vNode.Bus.Subscribe <SystemMessage.BecomeShutdown>(shutdownCallback);

                _vNode.Stop();

                shutdownCallback.Wait();

                _db.Dispose();
                _writerChk.Dispose();
                _chaserChk.Dispose();
                Directory.Delete(_db.Config.Path, true);

                _vNode = null;
                _db    = null;
            }
            catch (Exception)
            {
            }
        }
コード例 #4
0
 public void it_should_be_read_successfully()
 {
     _readCallback.Wait(msg => Assert.That(msg.Result == SingleReadResult.Success));
 }