/// <summary> /// Populates model with JSON string of serialized ClientStatus enum values /// </summary> /// <returns>Home View Model</returns> private static HomeViewModel PopulateViewModelWithEnumValues() { return(new HomeViewModel { ClientStatusJson = EnumHelpers.ConvertToJsonDictionary <ClientStatus>() }); }
public void ConvertToJsonDictionary_ShouldThrowArgumentException_WhenTypeIsInt() { // Arrange // Act Action action = () => EnumHelpers.ConvertToJsonDictionary <int>(); // Assert action.ShouldThrow <ArgumentException>(); }
public void ConvertToJsonDictionary_ShouldReturnEnumSerializedIntoJson_WhenTypeIsEnum() { // Arrange var expectedResult = $"{{\"{TestEnum.Item1}\":{(int)TestEnum.Item1},\"{TestEnum.Item2}\":{(int)TestEnum.Item2}}}"; // Act var result = EnumHelpers.ConvertToJsonDictionary <TestEnum>(); // Assert result.Should().Be(expectedResult); }