tests/DotNetCommon.Test/Extensions/GenericExtensions/GetDefaultTests.cs

(完整代码) 695B

using DotNetCommon.Extensions;
using NUnit.Framework;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text;

namespace DotNetCommon.Test.Extensions.GenericExtensions
{
    [TestFixture]
    internal class GetDefaultTests
    {
        [Test]
        public void Test()
        {
            typeof(int).GetDefault().ShouldBe(0);
            typeof(int?).GetDefault().ShouldBe(null);

            typeof(GetDefaultTests).GetDefault().ShouldBe(null);
            typeof(string).GetDefault().ShouldBe(null);

            typeof(double).GetDefault().ShouldBe(default(double));

            typeof(DateTime).GetDefault().ShouldBe(default(DateTime));
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。