Beispiel #1
0
        public async Task FileJournalSmokeTest()
        {
            var settings      = new MemstateSettings();
            var fileName      = Path.GetTempFileName();
            var journalWriter = new FileJournalWriter(settings, fileName, 0, int.MaxValue);
            var subSource     = new FileJournalSubscriptionSource(journalWriter);
            var records       = new List <JournalRecord>();
            var sub           = subSource.Subscribe(0, records.Add);

            for (int i = 0; i < 1000; i++)
            {
                var command = new AddStringCommand(i.ToString());
                journalWriter.Send(command);
            }

            await journalWriter.DisposeAsync().ConfigureAwait(false);

            sub.Dispose();
            subSource.Dispose();

            Assert.Equal(1000, records.Count);


            var reader = new FileJournalReader(fileName, settings);

            records.Clear();
            foreach (var record in reader.GetRecords())
            {
                records.Add(record);
            }
            Assert.True(records.Select(r => (int)r.RecordNumber).SequenceEqual(Enumerable.Range(0, 1000)));
            await reader.DisposeAsync().ConfigureAwait(false);

            File.Delete(fileName);
        }
Beispiel #2
0
        public void Command_keeps_id_after_serialization(ISerializer serializer)
        {
            var original = new AddStringCommand("dummy");
            var clone    = serializer.Clone(original);

            Assert.Equal(original.Id, clone.Id);
        }