public void Should_report_an_overflow_when_failed_to_acquire_a_buffer() { pool.TryAcquire(out _).Returns(false); sink.Put(Stream, _ => {}); stats.Received(1).ReportOverflow(); }
public void TestSetup() { timestamp = DateTimeOffset.UtcNow; item = Guid.NewGuid().ToString(); itemSerializer = Substitute.For <IAirlockSerializer <string> >(); buffer = Substitute.For <IBuffer>(); buffer.WrittenRecords.Returns(5); buffer.Position.Returns(10); bufferPool = Substitute.For <IBufferPool>(); bufferPool .TryAcquire(out _) .Returns( x => { x[0] = buffer; return(buffer != null); }); recordSerializer = Substitute.For <IRecordSerializer>(); recordSerializer .TrySerialize(item, itemSerializer, timestamp, buffer) .Returns(true); recordWriter = new RecordWriter(recordSerializer); }
public void TestSetup() { factory = Substitute.For <IStreamStateFactory>(); factory.Create(Arg.Any <string>()).Returns(_ => state); state = Substitute.For <IStreamState>(); state.BufferPool.Returns(_ => pool); state.Statistics.Returns(_ => stats); state.RecordWriter.Returns(_ => writer); state.SendSignal.Returns(new AsyncManualResetEvent(false)); buffer = Substitute.For <IBuffer>(); writer = Substitute.For <IRecordWriter>(); stats = Substitute.For <IStatisticsCollector>(); daemon = Substitute.For <IDaemon>(); pool = Substitute.For <IBufferPool>(); pool.TryAcquire(out _) .Returns( info => { info[0] = buffer; return(true); }); log = new SynchronousConsoleLog(); sink = new HerculesSink(factory, daemon, log); }