public void SendAfterOpenAndAfterErrorThrows() { var loggerFactory = new Mock <ILoggerFactory>(); var perfCounters = new SignalRPerformanceCounterManager(loggerFactory.Object); var logger = new Mock <ILogger>(); var stream = new ScaleoutStream(logger.Object, "0", QueuingBehavior.InitialOnly, 1000, perfCounters); int x = 0; var firstSend = stream.Send(_ => { x++; return(TaskAsyncHelper.Empty); }, null); stream.Open(); // Wait on the first send to drain firstSend.Wait(); stream.SetError(new Exception("Failed")); Assert.Throws <Exception>(() => { stream.Send(_ => { x++; return(TaskAsyncHelper.Empty); }, null).Wait(); }); Assert.Equal(1, x); }
public void SendAfterOpenAndAfterErrorThrows() { var perfCounters = new Microsoft.AspNet.SignalR.Infrastructure.PerformanceCounterManager(); var stream = new ScaleoutStream(new TraceSource("Queue"), "0", QueuingBehavior.InitialOnly, 1000, perfCounters); int x = 0; var firstSend = stream.Send(_ => { x++; return(TaskAsyncHelper.Empty); }, null); stream.Open(); // Wait on the first send to drain firstSend.Wait(); stream.SetError(new Exception("Failed")); Assert.Throws <Exception>(() => { stream.Send(_ => { x++; return(TaskAsyncHelper.Empty); }, null).Wait(); }); Assert.Equal(1, x); }
public async Task BufferAfterClosedEnqueueThrows() { var perfCounters = new Microsoft.AspNet.SignalR.Infrastructure.PerformanceCounterManager(); var stream = new ScaleoutStream(new TraceSource("Queue"), "0", QueuingBehavior.Always, 1000, perfCounters); stream.Close(); stream.SetError(new Exception()); await Assert.ThrowsAsync <Exception>(() => stream.Send(_ => TaskAsyncHelper.Empty, null)); }
public void BufferAfterClosedEnqueueThrows() { var loggerFactory = new Mock <ILoggerFactory>(); var perfCounters = new SignalRPerformanceCounterManager(loggerFactory.Object); var logger = new Mock <ILogger>(); var stream = new ScaleoutStream(logger.Object, "0", QueuingBehavior.Always, 1000, perfCounters); stream.Close(); stream.SetError(new Exception()); Assert.ThrowsAsync <Exception>(() => stream.Send(_ => TaskAsyncHelper.Empty, null)); }
public void InitialToBufferingToOpenToSend() { int x = 0; var perfCounters = new Microsoft.AspNet.SignalR.Infrastructure.PerformanceCounterManager(); var stream = new ScaleoutStream(new TraceSource("Queue"), "0", QueuingBehavior.Always, 1000, perfCounters); stream.SetError(new Exception()); stream.Open(); stream.Send(async _ => { await Task.Delay(20); x++; }, null).Wait(); Assert.Equal(1, x); }
public void InitialToBufferingToOpenToSend() { int x = 0; var loggerFactory = new Mock <ILoggerFactory>(); var perfCounters = new SignalRPerformanceCounterManager(loggerFactory.Object); var logger = new Mock <ILogger>(); var stream = new ScaleoutStream(logger.Object, "0", QueuingBehavior.Always, 1000, perfCounters); stream.SetError(new Exception()); stream.Open(); stream.Send(async _ => { await Task.Delay(20); x++; }, null).Wait(); Assert.Equal(1, x); }