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); }
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); }