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)); }
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); }
public void TestValidValueCheck() { foreach (var value in validValues) { Assert.True(StringEnumTestModel.IsValidValue(value)); } foreach (var value in invalidValues) { Assert.False(StringEnumTestModel.IsValidValue(value)); } }
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); }
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); } }
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); }); } }
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); }); } }
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); } }
public void TestCount() { Assert.Equal(StringEnumTestModel.ENUMS_COUNT, StringEnumTestModel.GetAll().Count()); }