示例#1
0
        public void GetResultOf_NotWithAnySynchronizationContext_ThrowsInvalidOperationException()
        {
            var worker    = new AsynchronousWorker();
            var remaining = Result.Of(worker.DoWork(2));

            Assert.AreEqual(4, remaining);
        }
示例#2
0
        public void GetResultOf_NotWithAnySynchronizationContext_ThrowsInvalidOperationException()
        {
            var sync = Container.Resolve <SyncClassOverrideContext>();

            sync.DoWork();

            var worker = new AsynchronousWorker();

            Assert.Throws <InvalidOperationException>(() => Result.Of(worker.DoWork(2)));
        }
示例#3
0
 public void Execute()
 {
     // This intentionally avoids referencing AsynchronousWorkerTests types
     // because the assembly would fail to load
     _ = new AsynchronousWorker <int>(
         new Mock <IAsynchronousWorkerHandler <int> >().Object,
         new Mock <IWaiter>().Object,
         1,
         10,
         null);
 }
示例#4
0
        private AsynchronousWorker <int> CreateWorker(int workerThreadCount = 2)
        {
            var worker = new AsynchronousWorker <int>(
                _handler.Object,
                _waiter.Object,
                workerThreadCount,
                10,
                null);

            _workers.Add(worker);
            return(worker);
        }
    public AsyncSignalFxMetricWriter(ISignalFxMetricExporter exporter, int maxItems)
    {
        if (exporter == null)
        {
            throw new ArgumentNullException(nameof(exporter));
        }

        if (maxItems < 1)
        {
            throw new ArgumentOutOfRangeException(nameof(maxItems), "MaxItems has to be greater or equal to 1");
        }

        _worker = new AsynchronousWorker <DataPoint>(
            new BufferingWorker(exporter, maxItems),
            new Waiter(),
            1,
            maxItems,
            null);
    }
		public void GetResultOf_NotWithAnySynchronizationContext_ThrowsInvalidOperationException()
		{
			var sync = Container.Resolve<SyncClassOverrideContext>();
			sync.DoWork();

			var worker = new AsynchronousWorker();
			var remaining = Result.Of(worker.DoWork(2));
			Assert.AreEqual(4, remaining);
		}
		public void GetResultOf_NotWithAnySynchronizationContext_ThrowsInvalidOperationException()
		{
			var worker = new AsynchronousWorker();
			var remaining = Result.Of(worker.DoWork(2));
			Assert.AreEqual(4, remaining);
		}