예제 #1
0
        public void TestParsedEquals()
        {
            var x1 = StringEnumTestModel.Parse("a");
            var x2 = StringEnumTestModel.Parse("owo");
            var x3 = StringEnumTestModel.Parse("a,x");

            Assert.True(StringEnumTestModel.A.Equals(x1));
            Assert.True(StringEnumTestModel.OwO.Equals(x2));
            Assert.True((StringEnumTestModel.A | StringEnumTestModel.X).Equals(x3));
        }
예제 #2
0
        public void TestNullEqualityComparer()
        {
            Assert.False(StringEnumTestModel.A == null);
            Assert.False(null == StringEnumTestModel.A);
            Assert.True(StringEnumTestModel.A != null);
            Assert.True(null != StringEnumTestModel.A);

            StringEnumTestModel e = null;

            Assert.True(e == null);
            Assert.False(e == StringEnumTestModel.C);
        }
예제 #3
0
        public void TestValidValueCheck()
        {
            foreach (var value in validValues)
            {
                Assert.True(StringEnumTestModel.IsValidValue(value));
            }

            foreach (var value in invalidValues)
            {
                Assert.False(StringEnumTestModel.IsValidValue(value));
            }
        }
예제 #4
0
        public void ParseNameTest()
        {
            var x = StringEnumTestModel.Parse("x");

            Assert.Equal("X", x.Name);

            var owo1 = StringEnumTestModel.Parse("owo");
            var owo2 = StringEnumTestModel.Parse("OWO");

            Assert.Equal("OwO", owo1.Name);
            Assert.Equal("OwO", owo2.Name);
        }
예제 #5
0
 public void TryParseTest()
 {
     foreach (var value in parseOkValues)
     {
         var parseRes = StringEnumTestModel.TryParse(value, out var res);
         Assert.True(parseRes);
         Assert.Equal(StringEnumTestModel.A, res);
     }
     foreach (var value in parseArgumentExceptionValues)
     {
         var parseRes = StringEnumTestModel.TryParse(value, out var res);
         Assert.False(parseRes);
         Assert.Null(res);
     }
 }
예제 #6
0
 public void ParseTest()
 {
     foreach (var value in parseOkValues)
     {
         var e = StringEnumTestModel.Parse(value);
         Assert.Equal(StringEnumTestModel.A, e);
     }
     foreach (var value in parseArgumentExceptionValues)
     {
         Assert.Throws <ArgumentException>(() =>
         {
             StringEnumTestModel.Parse(value);
         });
     }
 }
예제 #7
0
        public void ParseFlagsTest()
        {
            var eExpected = StringEnumTestModel.A | StringEnumTestModel.B;

            foreach (var value in parseValidFlags)
            {
                Assert.Equal(eExpected, StringEnumTestModel.Parse(value));
            }

            foreach (var value in parseArgumentExceptionFlags)
            {
                Assert.Throws <ArgumentException>(() =>
                {
                    StringEnumTestModel.Parse(value);
                });
            }
        }
예제 #8
0
        public void TryParseFlagsTest()
        {
            var eExpected = StringEnumTestModel.A | StringEnumTestModel.B;

            foreach (var value in parseValidFlags)
            {
                var parseRes = StringEnumTestModel.TryParse(value, out var res);
                Assert.True(parseRes);
                Assert.Equal(eExpected, res);
            }

            foreach (var value in parseArgumentExceptionFlags)
            {
                var parseRes = StringEnumTestModel.TryParse(value, out var res);
                Assert.False(parseRes);
                Assert.Null(res);
            }
        }
예제 #9
0
 public void TestCount()
 {
     Assert.Equal(StringEnumTestModel.ENUMS_COUNT, StringEnumTestModel.GetAll().Count());
 }