コード例 #1
0
ファイル: ImmutableCommand.cs プロジェクト: Ackara/NShellit
 public ImmutableCommand(int id, string name, DateTime dob, FakeEnum category, params int[] accessCodes)
 {
     Id          = id;
     Dob         = dob;
     Name        = name;
     Category    = category;
     AccessCodes = accessCodes;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void Add(string name, FakeEnum fakeEnum)
 {
     _enums.AddOrUpdate(name, fakeEnum);
 }
コード例 #6
0
        public void TestEnumOptionParsingFromConstructor(string rawText, FakeEnum expected)
        {
            EnumCommandOption <FakeEnum> option = new EnumCommandOption <FakeEnum>(CommandOptionKind.Date, rawText);

            Assert.Equal(expected, option.GetValue(null));
        }
コード例 #7
0
        public void ConvertToOrDefault_WhenAEnumItemIsGiven_ShouldConvertToTheCorrespondentIndex(FakeEnum enumItem, int enumIndex)
        {
            // Act
            var result = enumItem.ConvertToOrDefault <int>();

            // Assert
            Assert.That(result, Is.EqualTo(enumIndex));
        }
コード例 #8
0
 private void Convert_of_EnumA_to_EnumB_By_InvalidB_Inference_Types_Throws_Exception_MethodThatThrows()
 {
     FakeEnum fakeEnum;
     FakeEnum result = EnumLibrary.Convert(EnumA.Foo, fakeEnum);
 }
コード例 #9
0
 private void Convert_of_EnumA_to_EnumB_By_InvalidB_Types_Throws_Exception_MethodThatThrows()
 {
     FakeEnum result = EnumLibrary.Convert <EnumA, FakeEnum>(EnumA.Foo);
 }
コード例 #10
0
 public void ShouldReturnCorrectEnumFromDescription(string description, FakeEnum expectedEnum)
 {
     Assert.AreEqual(expectedEnum, EnumHelpers.GetEnumFromEnumDescription <FakeEnum>(description));
 }
コード例 #11
0
 public void ShouldReturnCorrectEnumString(FakeEnum value, string expectedValue)
 {
     Assert.AreEqual(expectedValue, EnumHelpers.GetEnumDescriptionFromEnum(value));
 }