示例#1
0
        public async Task HandleNonNullableEnumWithInvalidStringValue_Returns_DefaultValue()
        {
            var enumModelBinderService = new EnumModelBinderService();
            var invalidValue           = "Invalid string";

            var handledValue = await enumModelBinderService.BuildModelAsync(typeof(StudentTypes), invalidValue);

            Assert.AreEqual(default(StudentTypes), (StudentTypes)handledValue);
        }
示例#2
0
        public void HandleNullableEnumWithValidStringValue_Returns_ValidEnum()
        {
            var enumModelBinderService = new EnumModelBinderService();
            var goodString             = $"{nameof(StudentTypes.Good)}";

            var handledResult = enumModelBinderService.BuildModelAsync(typeof(StudentTypes?), goodString)
                                .Result;

            Assert.AreEqual(StudentTypes.Good, handledResult);
        }