Click here to Skip to main content
15,895,370 members
Articles / Programming Languages / C# 4.0

Extended Thread Pool

Rate me:
Please Sign up or sign in to vote.
4.98/5 (25 votes)
6 Apr 2013Ms-PL3 min read 81.9K   1.8K   119  
Your own extensible and configurable Thread Pool.
using Nelibur.Sword.DataStructures;
using Nelibur.Sword.Extensions;
using Xunit;

namespace UnitTests.Nelibur.Sword.Extensions
{
    public sealed class ObjectExtensionsTests
    {
        [Fact]
        public void IsNotNull_NotNull_True()
        {
            Assert.True(new object().IsNotNull());
        }

        [Fact]
        public void IsNotNull_Null_False()
        {
            object value = null;
            Assert.False(value.IsNotNull());
        }

        [Fact]
        public void IsNull_NotNull_False()
        {
            Assert.False(new object().IsNull());
        }

        [Fact]
        public void IsNull_Null_True()
        {
            Assert.True(ObjectExtensions.IsNull(null));
        }

        [Fact]
        public void ToBag_Null_Empty()
        {
            Assert.False(((object)(null)).ToOption().HasValue);
        }

        [Fact]
        public void ToBag_Null_NotEmpty()
        {
            Assert.True(new object().ToOption().HasValue);
        }

        [Fact]
        public void ToType_InvalidType_HasNoValue()
        {
            object value = 1;
            Option<bool> result = value.ToType<bool>();
            Assert.True(result.HasNoValue);
        }

        [Fact]
        public void ToType_ValidType_HasValue()
        {
            object value = true;
            Option<bool> result = value.ToType<bool>();
            Assert.True(result.HasValue);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior)
United States United States
B.Sc. in Computer Science.

Comments and Discussions