public ImmutableCommand(int id, string name, DateTime dob, FakeEnum category, params int[] accessCodes) { Id = id; Dob = dob; Name = name; Category = category; AccessCodes = accessCodes; }
public void TestParse(string input, FakeEnum expectedEnumValue) { EnumArgumentToken <FakeEnum> token = new EnumArgumentToken <FakeEnum> .Builder().Name("name").IsOptional(false).Build(); FakeEnum enumValue; bool match = EnumArgumentToken <FakeEnum> .TryParse(input, out enumValue); Assert.True(match); Assert.Equal(expectedEnumValue, enumValue); }
public FakeEnum GetEnumIndex(string fullName, out int index) { FakeEnum fakeEnum = GetFakeEnum(fullName); if (fakeEnum == null) { index = -1; return(null); } var splitName = fullName.Split('.'); fakeEnum.TryParse(splitName.Length > 1 ? splitName[1] : fullName, out index); return(fakeEnum); }
public void TestEnumOptionParsing() { FakeEnum value1 = FakeEnum.SecondItem; EnumCommandOption <FakeEnum> option = new EnumCommandOption <FakeEnum>(CommandOptionKind.Date); FakeEnum parsedData; bool successful = option.TryParseData("SecondItem", out parsedData); Assert.True(successful); Assert.Equal(value1, parsedData); successful = option.SetData("asdf"); Assert.False(successful); Assert.False(option.IsDataValid); successful = option.SetData("ThirdItem"); Assert.True(successful); Assert.True(option.IsDataValid); }
public void Add(string name, FakeEnum fakeEnum) { _enums.AddOrUpdate(name, fakeEnum); }
public void TestEnumOptionParsingFromConstructor(string rawText, FakeEnum expected) { EnumCommandOption <FakeEnum> option = new EnumCommandOption <FakeEnum>(CommandOptionKind.Date, rawText); Assert.Equal(expected, option.GetValue(null)); }
public void ConvertToOrDefault_WhenAEnumItemIsGiven_ShouldConvertToTheCorrespondentIndex(FakeEnum enumItem, int enumIndex) { // Act var result = enumItem.ConvertToOrDefault <int>(); // Assert Assert.That(result, Is.EqualTo(enumIndex)); }
private void Convert_of_EnumA_to_EnumB_By_InvalidB_Inference_Types_Throws_Exception_MethodThatThrows() { FakeEnum fakeEnum; FakeEnum result = EnumLibrary.Convert(EnumA.Foo, fakeEnum); }
private void Convert_of_EnumA_to_EnumB_By_InvalidB_Types_Throws_Exception_MethodThatThrows() { FakeEnum result = EnumLibrary.Convert <EnumA, FakeEnum>(EnumA.Foo); }
public void ShouldReturnCorrectEnumFromDescription(string description, FakeEnum expectedEnum) { Assert.AreEqual(expectedEnum, EnumHelpers.GetEnumFromEnumDescription <FakeEnum>(description)); }
public void ShouldReturnCorrectEnumString(FakeEnum value, string expectedValue) { Assert.AreEqual(expectedValue, EnumHelpers.GetEnumDescriptionFromEnum(value)); }