public static async Task StartNew <T> ( IEnumerable <T> initialItems, Func <T, CancellationToken, IEnumerable <T> > action, CancellationToken cancellationToken, SearchTaskOptions options = null ) { var notNullAction = Argument.IsNotNull(action, nameof(action)); var notNullInitialItems = Argument.IsNotNull(initialItems, nameof(initialItems)); var items = notNullInitialItems.Value.ToArray(); if (items.Length == 0) { throw new ArgumentException(@"Initial items collection cannot be empty", nameof(initialItems)); } var queueOptions = NotNull <SearchTaskOptions> .Create(options ?? new SearchTaskOptions()); var queue = NotNull <IBlockingQueue <HierarchyElement <T> > > .Create ( new HierarchicalLimitedBlockingQueue <T>(items, queueOptions.Value.MaxQueueLength, queueOptions.Value.MaxHierarchyDepth) ); await Task.Run ( () => { Process(queue, notNullAction, cancellationToken, queueOptions); }, cancellationToken ); }
public static async Task StartNew(Action action, int parallelCount) { Argument.IsNotNull(action, nameof(action)); Argument.IsInRange(parallelCount, nameof(parallelCount), 2, int.MaxValue); var actions = NotNull <IEnumerable <Action> > .Create(Enumerable.Repeat(action, parallelCount)); await StartCore(actions); }
public void NotNullTest() { var obj = new object(); var notNullObj = NotNull <object> .Create(obj); Assert.IsNotNull(notNullObj); Assert.IsNotNull(notNullObj.Value); }
public void NotNullFailsOnNullValueArgumentTest() { var exception = Assert.Throws <ArgumentNullException> ( () => { NotNull <object> .Create(null); } ); Assert.AreEqual(@"value", exception.ParamName); }
public static void TestCreateWithNullExpectException() { Assert.That(() => NotNull <object> .Create(null), Throws.Exception); }
public static void TestValueWithNotNullExpectSuccess() { NotNull <string> nn = NotNull <string> .Create("test"); Assert.That(nn.Value.Length, Is.EqualTo(4)); }
public static void TestImplicitConversionWithNotNullExpectSuccess() { NotNull <string> nn = NotNull <string> .Create("test"); Assert.That(((string)nn).Length, Is.EqualTo(4)); }
public static void TestCreateWithNotNullExpectSuccess() { Assert.That(() => NotNull <object> .Create(new object()), Throws.Nothing); }