Пример #1
0
        public void ShouldParseUsingFromValue()
        {
            FakeEnumeration temp;

            FakeEnumeration.FromValue(1).Should().Be(FakeEnumeration.One);
            FakeEnumeration.TryParse(1, out temp).Should().BeTrue();
        }
Пример #2
0
        public void ShouldParseUsingDisplayName()
        {
            FakeEnumeration temp;

            FakeEnumeration.Parse("one").Should().Be(FakeEnumeration.One);
            FakeEnumeration.TryParse("one", out temp).Should().BeTrue();
        }
Пример #3
0
        public void ShouldThrowArgumentExceptionWhenBadValue()
        {
            var e = Record.Exception(() => FakeEnumeration.FromValue(-1));

            e.Should().BeOfType <ArgumentException>();
            e.Message.Should().Contain((-1).ToString());
            e.Message.Should().Contain(typeof(FakeEnumeration).FullName);
            FakeEnumeration.TryParse(-1, out var temp).Should().BeFalse();
        }
Пример #4
0
        public void ShouldThrowArgumentExceptionWhenBadDisplayName()
        {
            var e = Record.Exception(() => FakeEnumeration.Parse("test"));

            e.Should().BeOfType <ArgumentException>();
            e.Message.Should().Contain(typeof(FakeEnumeration).FullName);
            e.Message.Should().Contain("test");
            FakeEnumeration.TryParse("temp", out var temp).Should().BeFalse();
        }