public void EnumViewModelConverter_Convert() { EnumViewModelConverter converter = new EnumViewModelConverter(); List <Enum> enumValues = new List <Enum>(); enumValues.AddRange(Enum.GetValues(typeof(FitnessType)).Cast <Enum>()); enumValues.AddRange(Enum.GetValues(typeof(FitnessSortOption)).Cast <Enum>()); object result; foreach (Enum val in enumValues) { result = converter.Convert(val, null, null, null); EnumViewModel viewModel = (EnumViewModel)result; Assert.Equal(val, viewModel.Value); Assert.True(!(String.IsNullOrEmpty(viewModel.DisplayName))); } result = converter.Convert((FitnessType)20, null, null, null); Assert.Null(result); result = converter.Convert((FitnessSortOption)20, null, null, null); Assert.Null(result); result = converter.Convert(null, null, null, null); Assert.Null(result); }
public void EnumViewModelConverter_ConvertBack() { EnumViewModelConverter converter = new EnumViewModelConverter(); object result; EnumViewModel viewModel = new EnumViewModel(FitnessType.Raw, "Test"); result = converter.ConvertBack(viewModel, null, null, null); Assert.Equal(viewModel.Value, result); result = converter.ConvertBack(null, null, null, null); Assert.Null(result); }