コード例 #1
0
            public void Should_Throw_If_TagName_Is_Null()
            {
                // Given
                var fixture = new GitReleaseManagerPublisherFixture();

                fixture.TagName = string.Empty;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsArgumentNullException(result, "tagName");
            }
コード例 #2
0
 public void ThrowsTest2()
 {
     try
     {
         Action action = () => { };
         AssertEx.Throws <ApplicationException>(action);
     }
     catch (System.Exception ex)
     {
         Assert.IsInstanceOfType(ex, typeof(AssertFailedException));
         Assert.AreEqual("AssertEx.Throws に失敗しました。例外が発生しません。", ex.Message);
     }
 }
コード例 #3
0
            public void Should_Throw_If_GitReleaseManager_Executable_Was_Not_Found()
            {
                // Given
                var fixture = new GitReleaseManagerPublisherFixture();

                fixture.GivenDefaultToolDoNotExist();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "GitReleaseManager: Could not locate executable.");
            }
コード例 #4
0
        public void TargetBlockTest()
        {
            foreach (var block in Blocks.CreateTargetBlocks <int> ())
            {
                // invalid header
                AssertEx.Throws <ArgumentException> (
                    () => block.OfferMessage(new DataflowMessageHeader(), 42, null, false));

                // consumeToAccept with null source
                AssertEx.Throws <ArgumentException> (
                    () => block.OfferMessage(new DataflowMessageHeader(1), 42, null, true));
            }
        }
コード例 #5
0
ファイル: VSWhereAllTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new VSWhereAllFixture();

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "VSWhere: Process was not started.");
            }
コード例 #6
0
ファイル: AppVeyorProviderTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_Not_Running_On_AppVeyor()
            {
                // Given
                var fixture  = new AppVeyorFixture();
                var appVeyor = fixture.CreateAppVeyorService();

                // When
                var result = Record.Exception(() => appVeyor.UploadTestResults("./file.xml", AppVeyorTestResultsType.XUnit));

                // Then
                AssertEx.IsExceptionWithMessage <CakeException>(result,
                                                                "The current build is not running on AppVeyor.");
            }
コード例 #7
0
ファイル: AppVeyorProviderTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_Build_Version_Is_Empty(string version)
            {
                // Given
                var fixture  = new AppVeyorFixture();
                var appVeyor = fixture.CreateAppVeyorService();

                // When
                var result = Record.Exception(() => appVeyor.UpdateBuildVersion(version));

                // Then
                AssertEx.IsExceptionWithMessage <CakeException>(result,
                                                                "The build version cannot be empty.");
            }
コード例 #8
0
        public void CustomAttributeArrayTypeEncoder_ElementType()
        {
            var b = new BlobBuilder();
            var e = new CustomAttributeArrayTypeEncoder(b);

            Assert.Same(b, e.Builder);

            var s = e.ElementType();

            AssertEx.Equal(new byte[] { 0x1D }, b.ToArray());
            Assert.Same(b, s.Builder);
            b.Clear();
        }
コード例 #9
0
        public async Task which_was_already_deleted_should_fail()
        {
            const string stream = "which_was_allready_deleted_should_fail";

            using (var connection = BuildConnection(_node)) {
                await connection.ConnectAsync();

                await connection.DeleteStreamAsync(stream, ExpectedVersion.NoStream, hardDelete : true);

                await AssertEx.ThrowsAsync <StreamDeletedException>(
                    () => connection.DeleteStreamAsync(stream, ExpectedVersion.Any, hardDelete: true));
            }
        }
コード例 #10
0
ファイル: AppVeyorProviderTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_Not_Running_On_AppVeyor()
            {
                // Given
                var fixture  = new AppVeyorFixture();
                var appVeyor = fixture.CreateAppVeyorService();

                // When
                var result = Record.Exception(() => appVeyor.AddMessage("Hello world"));

                // Then
                AssertEx.IsExceptionWithMessage <CakeException>(result,
                                                                "The current build is not running on AppVeyor.");
            }
コード例 #11
0
        public void BatchBlockTest()
        {
            AssertEx.Throws <ArgumentOutOfRangeException> (() => new BatchBlock <int> (0));
            AssertEx.Throws <ArgumentOutOfRangeException> (() => new BatchBlock <int> (-1));

            AssertEx.Throws <ArgumentOutOfRangeException> (
                () => new BatchBlock <int> (2,
                                            new GroupingDataflowBlockOptions {
                BoundedCapacity = 1
            }));

            AssertEx.Throws <ArgumentNullException> (() => new BatchBlock <int> (2, null));
        }
コード例 #12
0
        public void Args_Interactive2()
        {
            var runner = CreateRunner(
                args: new[] { "/u:System", "/i", "--", "@arg1", "/arg2", "-arg3", "--arg4" },
                input: "foreach (var arg in Args) Print(arg);");

            runner.RunInteractive();

            var error = $@"error CS2001: Source file '{Path.Combine(AppContext.BaseDirectory, "@arg1")}' could not be found.";

            AssertEx.AssertEqualToleratingWhitespaceDifferences(error, runner.Console.Out.ToString());
            AssertEx.AssertEqualToleratingWhitespaceDifferences(error, runner.Console.Error.ToString());
        }
コード例 #13
0
ファイル: VSWhereAllTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new VSWhereAllFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }
コード例 #14
0
ファイル: VSWhereAllTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_VSWhere_Executable_Was_Not_Found()
            {
                // Given
                var fixture = new VSWhereAllFixture();

                fixture.GivenDefaultToolDoNotExist();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "VSWhere: Could not locate executable.");
            }
コード例 #15
0
ファイル: MSTestRunnerTests.cs プロジェクト: worming004/cake
        public void Should_Throw_If_Assembly_Path_Is_Null()
        {
            // Given
            var fixture = new MSTestRunnerFixture();

            fixture.AssemblyPaths = null;

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            AssertEx.IsArgumentNullException(result, "assemblyPaths");
        }
コード例 #16
0
        public async Task TestDiagnosticSpan()
        {
            var source = @"// empty code";

            var analyzer = new InvalidSpanAnalyzer();
            using (var compilerEngineWorkspace = TestWorkspace.CreateCSharp(source))
            {
                var compilerEngineCompilation = (CSharpCompilation)(await compilerEngineWorkspace.CurrentSolution.Projects.Single().GetCompilationAsync());

                var diagnostics = compilerEngineCompilation.GetAnalyzerDiagnostics(new[] { analyzer });
                AssertEx.Any(diagnostics, d => d.Id == AnalyzerHelper.AnalyzerExceptionDiagnosticId);
            }
        }
コード例 #17
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryCommentsClient(connection);

            await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "name", "sha", new NewCommitComment("body")));
            await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "name", "sha", new NewCommitComment("body")));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", null, "sha", new NewCommitComment("body")));
            await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "", "sha", new NewCommitComment("body")));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", null, new NewCommitComment("body")));
            await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "name", "", new NewCommitComment("body")));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", "sha", null));
        }
コード例 #18
0
ファイル: SystemInfoTests.cs プロジェクト: runnane/PrtgAPI
        public async Task SystemInfo_ReadOnlyUserAsync()
        {
            var client = Initialize_Client(new SystemInfoResponse());

            var info = await client.GetSystemInfoAsync(1001);

            var properties = info.GetType().GetProperties();

            foreach (var prop in properties)
            {
                AssertEx.AllPropertiesRetrieveValues(prop.GetValue(info));
            }
        }
コード例 #19
0
        public void FromBytes_LargeSpan()
        {
            var bytes = Encoding.Unicode.GetBytes(LargeSource);
            var paddedBytes = new byte[] { 0 }.Concat(bytes).Concat(new byte[] { 0 }).ToArray();
            var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha256);
            var text     = EmbeddedText.FromBytes("pathToLarge", new ArraySegment <byte>(paddedBytes, 1, bytes.Length), SourceHashAlgorithm.Sha256);

            Assert.Equal("pathToLarge", text.FilePath);
            AssertEx.Equal(checksum, text.Checksum);
            Assert.Equal(SourceHashAlgorithm.Sha256, text.ChecksumAlgorithm);
            AssertEx.Equal(BitConverter.GetBytes(bytes.Length), text.Blob.Take(4));
            AssertEx.Equal(bytes, Decompress(text.Blob.Skip(4)));
        }
コード例 #20
0
        public void FromTextReader_Large()
        {
            var expected         = SourceText.From(LargeSource, Encoding.UTF8, SourceHashAlgorithm.Sha1);
            var expectedEmbedded = EmbeddedText.FromSource("pathToSmall", expected);

            var actual         = SourceText.From(new StringReader(LargeSource), LargeSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1);
            var actualEmbedded = EmbeddedText.FromSource(expectedEmbedded.FilePath, actual);

            Assert.Equal(expectedEmbedded.FilePath, actualEmbedded.FilePath);
            Assert.Equal(expectedEmbedded.ChecksumAlgorithm, actualEmbedded.ChecksumAlgorithm);
            AssertEx.Equal(expectedEmbedded.Checksum, actualEmbedded.Checksum);
            AssertEx.Equal(expectedEmbedded.Blob, actualEmbedded.Blob);
        }
コード例 #21
0
            public void UpperBoundOfDelayIsMaxDelay()
            {
#if !NETCOREAPP1_1
                var manager = new BackoffLogicManager(TimeSpan.Zero, TimeSpan.Zero);

                PrivateObject wrapper = new PrivateObject(manager);
                wrapper.SetField("consecutiveErrors", int.MaxValue);

                manager.GetBackOffTimeInterval(string.Empty);

                AssertEx.InRange(manager.CurrentDelay, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(3600));
#endif
            }
コード例 #22
0
        public void FromBytes_SmallSpan()
        {
            var bytes = Encoding.UTF8.GetBytes(SmallSource);
            var paddedBytes = new byte[] { 0 }.Concat(bytes).Concat(new byte[] { 0 }).ToArray();
            var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1);
            var text     = EmbeddedText.FromBytes("pathToSmall", new ArraySegment <byte>(paddedBytes, 1, bytes.Length));

            Assert.Equal("pathToSmall", text.FilePath);
            AssertEx.Equal(checksum, text.Checksum);
            Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm);
            AssertEx.Equal(new byte[] { 0, 0, 0, 0 }, text.Blob.Take(4));
            AssertEx.Equal(bytes, text.Blob.Skip(4));
        }
コード例 #23
0
 public override void When()
 {
     BecomeLeader();
     // All of the nodes have acked the first write
     WriterCheckpoint.Write(_firstLogPosition);
     WriterCheckpoint.Flush();
     Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replica1, _firstLogPosition));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replica2, _firstLogPosition - 100));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(Guid.NewGuid(), _firstLogPosition - 100));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(Guid.NewGuid(), _firstLogPosition - 100));
     AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
 }
コード例 #24
0
        public void Script_BadUsings()
        {
            var script = Temp.CreateFile(extension: ".csx").WriteAllText("WriteLine(42);");

            var runner = CreateRunner(new[] { "/u:System.Console;Foo.Bar", script.Path });

            Assert.Equal(1, runner.RunInteractive());

            const string error = @"error CS0246: The type or namespace name 'Foo' could not be found (are you missing a using directive or an assembly reference?)";

            AssertEx.AssertEqualToleratingWhitespaceDifferences(error, runner.Console.Out.ToString());
            AssertEx.AssertEqualToleratingWhitespaceDifferences(error, runner.Console.Error.ToString());
        }
コード例 #25
0
ファイル: VSWhereAllTests.cs プロジェクト: zokiz/cake
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new VSWhereAllFixture();

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "VSWhere: Process returned an error (exit code 1).");
            }
コード例 #26
0
ファイル: AssemblyIdentityTests.cs プロジェクト: znatz/roslyn
        public void Keys()
        {
            var an = new AssemblyName();

            an.Name    = "Foo";
            an.Version = new Version(1, 0, 0, 0);
            an.SetPublicKey(PublicKey1);
            var anPkt = an.GetPublicKeyToken();
            var aiPkt = AssemblyIdentity.CalculatePublicKeyToken(RoPublicKey1);

            AssertEx.Equal(PublicKeyToken1, anPkt);
            AssertEx.Equal(PublicKeyToken1, aiPkt);
        }
コード例 #27
0
        public void DBFiles_StringDictionary_07_DataTypes()
        {
            DateTime       DT  = DateTime.Now;
            DateTimeOffset DTO = DateTimeOffset.Now;

            this.file["Key1"]  = true;
            this.file["Key2"]  = (byte)1;
            this.file["Key3"]  = (short)2;
            this.file["Key4"]  = (int)3;
            this.file["Key5"]  = (long)4;
            this.file["Key6"]  = (sbyte)5;
            this.file["Key7"]  = (ushort)6;
            this.file["Key8"]  = (uint)7;
            this.file["Key9"]  = (ulong)8;
            this.file["Key10"] = (decimal)9;
            this.file["Key11"] = (double)10;
            this.file["Key12"] = (float)11;
            this.file["Key13"] = DT;
            this.file["Key14"] = TimeSpan.Zero;
            this.file["Key15"] = 'a';
            this.file["Key16"] = "Hello";
            this.file["Key17"] = NormalEnum.Option2;
            this.file["Key18"] = Guid.Empty.ToByteArray();
            this.file["Key19"] = Guid.Empty;
            this.file["Key20"] = DTO;
            this.file["Key21"] = new CaseInsensitiveString("Hello");
            this.file["Key22"] = null;

            AssertEx.Same(this.file["Key1"], true);
            AssertEx.Same(this.file["Key2"], (byte)1);
            AssertEx.Same(this.file["Key3"], (short)2);
            AssertEx.Same(this.file["Key4"], (int)3);
            AssertEx.Same(this.file["Key5"], (long)4);
            AssertEx.Same(this.file["Key6"], (sbyte)5);
            AssertEx.Same(this.file["Key7"], (ushort)6);
            AssertEx.Same(this.file["Key8"], (uint)7);
            AssertEx.Same(this.file["Key9"], (ulong)8);
            AssertEx.Same(this.file["Key10"], (decimal)9);
            AssertEx.Same(this.file["Key11"], (double)10);
            AssertEx.Same(this.file["Key12"], (float)11);
            AssertEx.Same(this.file["Key13"], DT);
            AssertEx.Same(this.file["Key14"], TimeSpan.Zero);
            AssertEx.Same(this.file["Key15"], 'a');
            AssertEx.Same(this.file["Key16"], "Hello");
            AssertEx.Same(this.file["Key17"], "Option2");
            AssertEx.Same(this.file["Key18"], Guid.Empty.ToByteArray());
            AssertEx.Same(this.file["Key19"], Guid.Empty);
            AssertEx.Same(this.file["Key20"], DTO);
            AssertEx.Same(this.file["Key21"], new CaseInsensitiveString("Hello"));
            Assert.IsNull(this.file["Key22"]);
        }
コード例 #28
0
ファイル: AssemblyIdentityTests.cs プロジェクト: znatz/roslyn
        public void MetadataConstructor()
        {
            var id = new AssemblyIdentity(/*noThrow:*/ true, "Foo", new Version(1, 2, 3, 4), "en-US", RoPublicKey1,
                                          hasPublicKey: true, isRetargetable: true, contentType: AssemblyContentType.Default);

            Assert.Equal("Foo", id.Name);
            Assert.Equal(new Version(1, 2, 3, 4), id.Version);
            Assert.Equal(AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable, id.Flags);
            Assert.Equal("en-US", id.CultureName);
            Assert.Equal(true, id.HasPublicKey);
            Assert.Equal(true, id.IsRetargetable);
            AssertEx.Equal(PublicKey1, id.PublicKey);
            AssertEx.Equal(PublicKeyToken1, id.PublicKeyToken);
            Assert.Equal(AssemblyContentType.Default, id.ContentType);

            // invalid content type:
            id = new AssemblyIdentity(/*noThrow:*/ true, "Foo", new Version(1, 2, 3, 4), null, ImmutableArray <byte> .Empty,
                                      hasPublicKey: false, isRetargetable: false, contentType: (AssemblyContentType)2);
            Assert.Equal(AssemblyNameFlags.None, id.Flags);
            Assert.Equal("", id.CultureName);
            Assert.Equal(false, id.HasPublicKey);
            Assert.Equal(0, id.PublicKey.Length);
            Assert.Equal(0, id.PublicKeyToken.Length);
            Assert.Equal(AssemblyContentType.Default, id.ContentType);

            // default Retargetable=No if content type is WinRT
            id = new AssemblyIdentity(/*noThrow:*/ true, "Foo", new Version(1, 2, 3, 4), null, ImmutableArray <byte> .Empty,
                                      hasPublicKey: false, isRetargetable: true, contentType: AssemblyContentType.WindowsRuntime);
            Assert.Equal("Foo", id.Name);
            Assert.Equal(new Version(1, 2, 3, 4), id.Version);
            Assert.Equal(AssemblyNameFlags.None, id.Flags);
            Assert.Equal("", id.CultureName);
            Assert.Equal(false, id.HasPublicKey);
            Assert.Equal(false, id.IsRetargetable);
            Assert.Equal(AssemblyContentType.WindowsRuntime, id.ContentType);

            // invalid culture:
            // The native compiler doesn't enforce that the culture be anything in particular.
            // AssemblyIdentity should preserve user input even if it is of dubious utility.
            id = new AssemblyIdentity(/*noThrow:*/ true, "Foo", new Version(1, 2, 3, 4), "blah,", ImmutableArray <byte> .Empty,
                                      hasPublicKey: false, isRetargetable: false, contentType: AssemblyContentType.Default);
            Assert.Equal("blah,", id.CultureName);

            id = new AssemblyIdentity(/*noThrow:*/ true, "Foo", new Version(1, 2, 3, 4), "*", ImmutableArray <byte> .Empty,
                                      hasPublicKey: false, isRetargetable: false, contentType: AssemblyContentType.Default);
            Assert.Equal("*", id.CultureName);

            id = new AssemblyIdentity(/*noThrow:*/ true, "Foo", new Version(1, 2, 3, 4), "neutral", ImmutableArray <byte> .Empty,
                                      hasPublicKey: false, isRetargetable: false, contentType: AssemblyContentType.Default);
            Assert.Equal("", id.CultureName);
        }
コード例 #29
0
        public void GenericType()
        {
            var source =
                @"using System.Diagnostics;
class A<T> where T : class
{
    [DebuggerDisplay(""{F(default(T), default(U))}"")]
    internal class B<U>
    {
        static object F<X, Y>(X x, Y y) where X : class
        {
            return x ?? (object)y;
        }
    }
}";
            var compilation0 = CreateCompilation(source, options: TestOptions.DebugDll, assemblyName: ExpressionCompilerUtilities.GenerateUniqueName());

            WithRuntimeInstance(compilation0, runtime =>
            {
                var context = CreateTypeContext(runtime, "A.B");
                string error;
                var testData    = new CompilationTestData();
                var result      = context.CompileExpression("F(default(T), default(U))", out error, testData);
                string actualIL = testData.GetMethodData("<>x<T, U>.<>m0").GetMethodIL();
                AssertEx.AssertEqualToleratingWhitespaceDifferences(
                    actualIL,
                    @"{
  // Code size       24 (0x18)
  .maxstack  2
  .locals init (T V_0,
  U V_1)
  IL_0000:  ldloca.s   V_0
  IL_0002:  initobj    ""T""
  IL_0008:  ldloc.0
  IL_0009:  ldloca.s   V_1
  IL_000b:  initobj    ""U""
  IL_0011:  ldloc.1
  IL_0012:  call       ""object A<T>.B<U>.F<T, U>(T, U)""
  IL_0017:  ret
}");
                // Verify generated type is generic, but method is not.
                using (var metadata = ModuleMetadata.CreateFromImage(ImmutableArray.CreateRange(result.Assembly)))
                {
                    var reader  = metadata.MetadataReader;
                    var typeDef = reader.GetTypeDef(result.TypeName);
                    reader.CheckTypeParameters(typeDef.GetGenericParameters(), "T", "U");
                    var methodDef = reader.GetMethodDef(typeDef, result.MethodName);
                    reader.CheckTypeParameters(methodDef.GetGenericParameters());
                }
            });
        }
コード例 #30
0
        public void ReceiveTest()
        {
            var source = new BufferBlock <int> ();

            source.Post(1);
            source.Post(2);
            source.Post(3);
            source.Post(4);

            AssertEx.Throws <ArgumentNullException> (
                () => DataflowBlock.Receive((ISourceBlock <int>)null));

            AssertEx.Throws <ArgumentNullException> (
                () => DataflowBlock.Receive((ISourceBlock <int>)null,
                                            new CancellationToken(false)));
            AssertEx.Throws <OperationCanceledException> (
                () => DataflowBlock.Receive(source, new CancellationToken(true)));

            AssertEx.Throws <ArgumentNullException> (
                () => DataflowBlock.Receive((ISourceBlock <int>)null,
                                            TimeSpan.FromMinutes(1)));
            // shouldn't throw
            DataflowBlock.Receive(source, TimeSpan.FromMilliseconds(-1));
            AssertEx.Throws <ArgumentOutOfRangeException> (
                () => DataflowBlock.Receive(source, TimeSpan.FromMilliseconds(-2)));
            // shouldn't throw
            DataflowBlock.Receive(source, TimeSpan.FromMilliseconds(int.MaxValue));
            AssertEx.Throws <ArgumentOutOfRangeException> (
                () => DataflowBlock.Receive(source,
                                            TimeSpan.FromMilliseconds(int.MaxValue + 1L)));

            AssertEx.Throws <ArgumentNullException> (
                () => DataflowBlock.Receive((ISourceBlock <int>)null,
                                            TimeSpan.FromMinutes(1), new CancellationToken(false)));
            AssertEx.Throws <OperationCanceledException> (
                () => DataflowBlock.Receive(source, TimeSpan.FromMinutes(1),
                                            new CancellationToken(true)));
            // shouldn't throw
            DataflowBlock.Receive(source, TimeSpan.FromMilliseconds(-1),
                                  new CancellationToken(false));
            AssertEx.Throws <ArgumentOutOfRangeException> (
                () => DataflowBlock.Receive(source, TimeSpan.FromMilliseconds(-2),
                                            new CancellationToken(false)));
            // shouldn't throw
            DataflowBlock.Receive(source, TimeSpan.FromMilliseconds(int.MaxValue),
                                  new CancellationToken(false));
            AssertEx.Throws <ArgumentOutOfRangeException> (
                () => DataflowBlock.Receive(source,
                                            TimeSpan.FromMilliseconds(int.MaxValue + 1L),
                                            new CancellationToken(false)));
        }