コード例 #1
0
        public void NonIntEnum_Tests()
        {
            var nie  = NonIntEnum.December;
            var nie2 = NonIntEnum.January;
            var nie3 = NonIntEnum.November;

            DateTime   d1   = NonIntEnum.December;
            string     s1   = NonIntEnum.December;
            NonIntEnum nie4 = "December 1st";
            NonIntEnum nie5 = DateTime.Parse("12/1/2020");

            nie.Should()
            .Be("December 1st");

            nie2.Should()
            .Be("January");

            nie3.Should()
            .Be(new DateTime(2020, 11, 1));

            d1.Should()
            .Be(NonIntEnum.December);
            s1.Should()
            .Be(NonIntEnum.December);
            nie4.Should()
            .Be(NonIntEnum.December);
            nie5.Should()
            .Be(NonIntEnum.December);
        }
コード例 #2
0
 public void Try_Tests()
 {
     NonIntEnum.TryConvert("December 1st", out _)
     .Should()
     .BeTrue();
     NonIntEnum.TryConvert("December 2nd", out _)
     .Should()
     .BeFalse();
     NonIntEnum.TryConvert(DateTime.Parse("11/1/2020"), out _)
     .Should()
     .BeTrue();
     NonIntEnum.TryConvert(DateTime.Parse("11/2/2020"), out _)
     .Should()
     .BeFalse();
 }