public void TestGetDescription() { SampleEnum val1 = SampleEnum.Val1; string desc = val1.GetDescription(); Assert.AreEqual("Value: 1", desc); }
public void Enum_RegistAlias() { EnumHelper.RegistAlias <SampleEnum>(enumValue => { return(new EnumAliasInfo(enumValue.ToString().ToUpper())); } ); bool result = EnumHelper.HasAlias(SampleEnum.Left); Assert.AreEqual(result, true); SampleEnum value = EnumHelper.FromAlias <SampleEnum>("LEFT"); Assert.AreEqual(value, SampleEnum.Left); string alias = EnumHelper.GetAlias(SampleEnum.Right); Assert.AreEqual(alias, "RIGHT"); EnumHelper.UnregistAlias <SampleEnum>(); result = EnumHelper.HasAlias(SampleEnum.Left); Assert.AreEqual(result, true); value = EnumHelper.FromAlias <SampleEnum>("L"); Assert.AreEqual(value, SampleEnum.Left); alias = EnumHelper.GetAlias(SampleEnum.Right); Assert.AreEqual(alias, "R"); }
public SampleSchema(int sampleInt, SampleEnum sampleEnum, string sampleString, byte[] sampleByteArr) { SampleInt = sampleInt; SampleEnum = sampleEnum; SampleString = sampleString; SampleByteArr = sampleByteArr; }
public void Initialize() { MyInt16 = 1; MyInt32 = 2; MyInt64 = 3; MyUInt16 = 4; MyUInt32 = 5; MyUInt64 = 6; MyByte = 7; MySByte = 8; MyChar = 'a'; MyString = "Hello"; MyBooleanTrue = true; MyBooleanFalse = false; MySingle = 1.1f; MyDouble = 2.2d; MyDecimal = 3.3m; MyDateTime = new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc); MyDateTimeOffset = new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)); MyEnum = SampleEnum.Two; MyInt16Array = new short[] { 1 }; MyInt32Array = new int[] { 2 }; MyInt64Array = new long[] { 3 }; MyUInt16Array = new ushort[] { 4 }; MyUInt32Array = new uint[] { 5 }; MyUInt64Array = new ulong[] { 6 }; MyByteArray = new byte[] { 7 }; MySByteArray = new sbyte[] { 8 }; MyCharArray = new char[] { 'a' }; MyStringArray = new string[] { "Hello" }; MyBooleanTrueArray = new bool[] { true }; MyBooleanFalseArray = new bool[] { false }; MySingleArray = new float[] { 1.1f }; MyDoubleArray = new double[] { 2.2d }; MyDecimalArray = new decimal[] { 3.3m }; MyDateTimeArray = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) }; MyDateTimeOffsetArray = new DateTimeOffset[] { new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)) }; MyEnumArray = new SampleEnum[] { SampleEnum.Two }; MyStringList = new List <string>() { "Hello" }; MyStringIEnumerableT = new string[] { "Hello" }; MyStringIListT = new string[] { "Hello" }; MyStringICollectionT = new string[] { "Hello" }; MyStringIReadOnlyCollectionT = new string[] { "Hello" }; MyStringIReadOnlyListT = new string[] { "Hello" }; MyStringToStringDict = new Dictionary <string, string> { { "key", "value" } }; MyStringToStringIDict = new Dictionary <string, string> { { "key", "value" } }; MyStringToStringIReadOnlyDict = new Dictionary <string, string> { { "key", "value" } }; }
public void TestGetDescriptionOutOfRange() { SampleEnum val = (SampleEnum)3; string desc = val.GetDescription(); Assert.AreEqual("Val2", desc); }
public void TestGetDescriptionNoFallback() { SampleEnum val = SampleEnum.Val2; string desc = val.GetDescription(); Assert.AreEqual("Val2", desc); }
public void FindCorrectName() { var sVal = SampleEnum.One.ToString(); SampleEnum se = Enum <SampleEnum> .FindByString(sVal); Assert.Equal(sVal, se.ToString()); }
public static void WriteArrayWithEnums() { var input = new SampleEnum[] { SampleEnum.One, SampleEnum.Two }; string json = JsonSerializer.ToString(input); Assert.Equal("[1,2]", json); }
public void FindNotCorrectNameWithDefault() { string sVal = "badSymbol"; SampleEnum se = Enum <SampleEnum> .FindByString(sVal, SampleEnum.Two); Assert.Equal(SampleEnum.Two, se); }
public SampleDto(int num, SampleEnum @enum, string name) { Id = num; Count = num; SampleField = @enum; Name = name; DateOfCreation = DateTime.UtcNow; }
public void OnGet(string selectedId, string selectedName, string requiredSelectedId, string requiredSelectedName, SampleEnum?selectedEnum, SampleEnum requiredSelectedEnum) { SelectedId = (selectedId == null)?"": selectedId; SelectedName = selectedName; RequiredSelectedId = (requiredSelectedId == null) ? "" : requiredSelectedId;; RequiredSelectedName = requiredSelectedName; SelectedEnum = selectedEnum; RequiredSelectedEnum = requiredSelectedEnum; }
// === Fake Method For Reflection === public void FakeMethod( [CliParameter("sets foo")] int foo, [CliParameter(_expectedAlias, "sets bar")] int?bar, string foobar = "null", List <int> barfoo = null, SampleEnum enumb = SampleEnum.EnumOne, List <SampleEnum> enumbs = null) { }
public void Check_TypeSupport_Enum() { SampleEnum obj = SampleEnum.Value2; using BinaryWriter writer = new BinaryWriter(); writer.Write(obj, typeof(SampleEnum)); using BinaryReader reader = new BinaryReader(writer.PackBytes()); Assert.AreEqual(obj, (SampleEnum)reader.Read(typeof(SampleEnum))); }
public void TestCheckInRange() { SampleEnum val1 = (SampleEnum)3; Assert.IsFalse(val1.IsValid()); SampleEnum val2 = (SampleEnum)2; Assert.IsTrue(val2.IsValid()); }
public void Check_TypeSupport_Enum_Array() { var arr = new SampleEnum[] { SampleEnum.Value2, SampleEnum.Value1, SampleEnum.Value1 }; HelperMethods.TestArray(arr); }
public void GetDescription_DefaultEnum_ReturnZeroToString() { // Arrange SampleEnum sample = default; // Act var ret = sample.GetDescription(); // Assert ret.Should().Be(0.ToString()); }
public static int test_0_enum_unbox() { SampleEnum x = SampleEnum.A; object o = x; int res = 1; res = (int)o; return(res); }
public void GetDescription_NoMatchingValue_ReturnToString() { // Arrange var evil = 666; SampleEnum sample = (SampleEnum)evil; // Act var ret = sample.GetDescription(); // Assert ret.Should().Be(evil.ToString()); }
/// <summary> /// This method is effectively pointless, but only called once. It's present (and called) /// to avoid the Unity linker from removing code that's only called via reflection. /// </summary> private static void PreventLinkerFailures() { // Exercise the method directly. This should avoid any pro-active linkers from stripping // the method out. SampleEnum x = SampleEnumMethod(); if (x != SampleEnum.X) { throw new InvalidOperationException("Failure in reflection utilities"); } // Make sure the ReflectionHelper parameterless constructor isn't removed... var helper = new ReflectionHelper <int, int>(); }
public void Bind_EnumTypeParameter_BindsParameter(string value, SampleEnum expected) { // arrange var sut = CreateCommandParameterBinder(typeof(ParameterTypesCommand)); var command = new ParameterTypesCommand(); var input = CreateCommandInput("command", new ParameterNameCommandParameter("enum"), (LiteralCommandParameter)value); // act var result = sut.Bind(command, input); // assert Assert.True(result.Success); Assert.Equal(expected, command.Enum); }
public void InlineAutoNSubstituteData_Should_Call_For_Each_Value( SampleEnum value, [Frozen] ISampleInterface interfaceType, SampleClass concreteType, SampleDependantClass dependantType) { value.Should().BeOneOf(SampleEnum.One, SampleEnum.Two, SampleEnum.Three); interfaceType.Should().NotBeNull(); interfaceType.IsSubstitute().Should().BeTrue(); concreteType.Should().NotBeNull(); concreteType.IsSubstitute().Should().BeFalse(); dependantType.Should().NotBeNull(); dependantType.Dependency.Should().Be(interfaceType); }
public static void GetAllEnumValues() { var enumFields = typeof(SampleEnum).GetFields(); var actualValues = new SampleEnum[enumFields.Length - 1]; for (var i = 1; i < enumFields.Length; ++i) { actualValues[i - 1] = (SampleEnum)enumFields[i].GetValue(null) !; } var expectedValues = (SampleEnum[])Enum.GetValues(typeof(SampleEnum)); actualValues.Should().Equal(expectedValues); }
internal static void RunSample(SampleEnum sample) { switch (sample) { case SampleEnum.Deconstruct: DeconstructorSampleUsing.PrintSample(); break; case SampleEnum.DictionaryDeconstruct: DeconstructorDictSample.PrintSample(); break; case SampleEnum.Switch: SwitchSample.PrintSample(); break; case SampleEnum.INstanceWitoutConstructorCall: INstanceWitoutConstructorCall.PrintSample(); break; case SampleEnum.Check_SQL_ARITHABORT: CheckSQL_ARITHABORT.PrintSample(); break; case SampleEnum.EFDisconectedRepoChangeLogSample: EFChangeLogSample.PrintDiscinectedSample(); break; case SampleEnum.EFConnectedRepoChangeLogSample: EFChangeLogSample.PrintConectedSample(); break; case SampleEnum.Двойная_Регистрация_DI: TwiceRegSample.PrintConectedSample(); break; case SampleEnum.FluentAsyncSample: AsyncFluentBuilderSample.RunSample(); break; case SampleEnum.EF_SoftDelete: EfSoftDeleteSample.PrintSoftDeleteSample(); break; default: throw new NotImplementedException(); } }
public void Initialize() { MyInt16 = (short)1; MyInt32 = (int)2; MyInt64 = (long)3; MyUInt16 = (ushort)4; MyUInt32 = (uint)5; MyUInt64 = (ulong)6; MyByte = (byte)7; MySByte = (sbyte)8; MyChar = 'a'; MyString = "Hello"; MyBooleanTrue = true; MyBooleanFalse = false; MySingle = 1.1f; MyDouble = 2.2d; MyDecimal = 3.3m; MyDateTime = new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc); MyEnum = SampleEnum.Two; MyInt16Array = new short[] { 1 }; MyInt32Array = new int[] { 2 }; MyInt64Array = new long[] { 3 }; MyUInt16Array = new ushort[] { 4 }; MyUInt32Array = new uint[] { 5 }; MyUInt64Array = new ulong[] { 6 }; MyByteArray = new byte[] { 7 }; MySByteArray = new sbyte[] { 8 }; MyCharArray = new char[] { 'a' }; MyStringArray = new string[] { "Hello" }; MyBooleanTrueArray = new bool[] { true }; MyBooleanFalseArray = new bool[] { false }; MySingleArray = new float[] { 1.1f }; MyDoubleArray = new double[] { 2.2d }; MyDecimalArray = new decimal[] { 3.3m }; MyDateTimeArray = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) }; MyEnumArray = new SampleEnum[] { SampleEnum.Two }; MyStringList = new List <string>() { "Hello" }; MyStringIEnumerableT = new string[] { "Hello" }; MyStringIListT = new string[] { "Hello" }; MyStringICollectionT = new string[] { "Hello" }; MyStringIReadOnlyCollectionT = new string[] { "Hello" }; MyStringIReadOnlyListT = new string[] { "Hello" }; }
public void Check_TypeSupport_Enum_Multi_Dimensional_Array() { var arr = new SampleEnum[][] { new SampleEnum[] { SampleEnum.Value2, SampleEnum.Value1, }, new SampleEnum[] { SampleEnum.Value1, SampleEnum.Value2, SampleEnum.Value3 } }; HelperMethods.TestArray(arr); }
public void Initialize() { MyInt16 = 1; MyInt32 = 2; MyInt64 = 3; MyUInt16 = 4; MyUInt32 = 5; MyUInt64 = 6; MyByte = 7; MyChar = 'a'; MyString = "Hello"; MyBooleanTrue = true; MyBooleanFalse = false; MySingle = 1.1f; MyDouble = 2.2d; MyDecimal = 3.3m; MyDateTime = new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc); MyEnum = SampleEnum.Two; }
public override void Initialize() { base.Initialize(); MyInt16Array = new short[] { 1 }; MyInt32Array = new int[] { 2 }; MyInt64Array = new long[] { 3 }; MyUInt16Array = new ushort[] { 4 }; MyUInt32Array = new uint[] { 5 }; MyUInt64Array = new ulong[] { 6 }; MyByteArray = new byte[] { 7 }; MySByteArray = new sbyte[] { 8 }; MyCharArray = new char[] { 'a' }; MyStringArray = new string[] { "Hello" }; MyBooleanTrueArray = new bool[] { true }; MyBooleanFalseArray = new bool[] { false }; MySingleArray = new float[] { 1.1f }; MyDoubleArray = new double[] { 2.2d }; MyDecimalArray = new decimal[] { 3.3m }; MyDateTimeArray = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) }; MyEnumArray = new SampleEnum[] { SampleEnum.Two }; MyStringList = new List <string>() { "Hello" }; MyStringIEnumerableT = new string[] { "Hello" }; MyStringIListT = new string[] { "Hello" }; MyStringICollectionT = new string[] { "Hello" }; MyStringIReadOnlyCollectionT = new string[] { "Hello" }; MyStringIReadOnlyListT = new string[] { "Hello" }; MyStringToStringDict = new Dictionary <string, string> { { "key", "value" } }; MyStringToStringIDict = new Dictionary <string, string> { { "key", "value" } }; MyStringToStringIReadOnlyDict = new Dictionary <string, string> { { "key", "value" } }; }
public void Load() { stringValue = Storage.instance.Load("string_key", "nothing previously saved"); boolValue = Storage.instance.Load("bool_key", false); enumValue = Storage.instance.Load("enum_key", SampleEnum.Option0); intValue = Storage.instance.Load("int_key", -1); floatValue = Storage.instance.Load("float_key", -1.0f); doubleValue = Storage.instance.Load("double_key", -1.0); listOfStrings = Storage.instance.LoadList("stringList_key", new List <string>()); arrayOfStrings = Storage.instance.LoadArray("stringArray_key", new string[0]); StringInputField.text = stringValue; BoolToggle.isOn = boolValue; EnumDropdown.value = (int)enumValue; IntInputField.text = intValue.ToString(); FloatInputField.text = floatValue.ToString(); DoubleInputField.text = doubleValue.ToString(); PopulateList(); PopulateArray(); }
public void TestEnumMethodSerialization(SoapSerializer soapSerializer) { var sampleServiceClient = _fixture.GetSampleServiceClient(soapSerializer); const SampleEnum output_value = SampleEnum.C; _fixture.ServiceMock .Setup(x => x.EnumMethod(out It.Ref <SampleEnum> .IsAny)) .Callback(new EnumMethodCallback( (out SampleEnum e_service) => { // sample response e_service = output_value; })) .Returns(true); var enumMethodResult_client = sampleServiceClient.EnumMethod(out var e_client); // check output paremeters serialization enumMethodResult_client.ShouldBe(true); e_client.ShouldBe(output_value); }
public SampleClassWithMultipleNonServiceArgumentConstructors(string arg1, int arg2, SampleEnum arg3, decimal arg4, int arg5) { }
public CustomAttributeWithSampleEnumArgumentsAttribute(SampleEnum value) { _value = value; }