public void Configure_TestAssembly_JsConfigFuncsSet() { //Inspecting static values, so locking in cases tests are multi threaded. lock (StaticTestingLocks.JsConfigLockObject) { JsConfig <FakeTestingEnum> .Reset(); JsConfig <FakeTestingEnum?> .Reset(); new EnumSerializerConfigurator() .WithAssemblies(new[] { typeof(FakeTestingEnum).GetTypeInfo().Assembly }) .WithNullableEnumSerializers() .Configure(); Func <FakeTestingEnum, string> expectedSerializeFunc = PrettyEnumHelpers <FakeTestingEnum> .GetOptimalEnumDescription; Func <string, FakeTestingEnum> expectedDeserializeFunc = PrettyEnumHelpers <FakeTestingEnum> .GetEnumFrom; Func <FakeTestingEnum?, string> expectedNullableSerializeFunc = PrettyEnumHelpers <FakeTestingEnum> .GetOptimalEnumDescription; Func <string, FakeTestingEnum?> expectedNullableDeserializeFunc = PrettyEnumHelpers <FakeTestingEnum> .GetNullableEnumFrom; Assert.Equal(expectedSerializeFunc, JsConfig <FakeTestingEnum> .SerializeFn); Assert.Equal(expectedDeserializeFunc.Target, JsConfigFnTargetResolver <FakeTestingEnum> .GetDeserializerTarget()); Assert.Equal(expectedNullableSerializeFunc, JsConfig <FakeTestingEnum?> .SerializeFn); Assert.Equal(expectedNullableDeserializeFunc.Target, JsConfigFnTargetResolver <FakeTestingEnum?> .GetDeserializerTarget()); } }
public void ConfigEnumSerializers_EnumType_JsConfigFuncsSet() { //Inspecting static values, so locking in cases tests are multi threaded. lock (StaticTestingLocks.JsConfigLockObject) { JsConfig <FakeTestingEnum> .Reset(); //Testing static class is fun var proxy = new EnumSerializerInitializerProxy(); proxy.ConfigEnumSerializers(typeof(FakeTestingEnum)); Func <FakeTestingEnum, string> expectedSerializeFunc = PrettyEnumHelpers <FakeTestingEnum> .GetOptimalEnumDescription; Func <string, FakeTestingEnum> expectedDeserializeFunc = PrettyEnumHelpers <FakeTestingEnum> .GetEnumFrom; Assert.Equal(expectedSerializeFunc.Target, JsConfig <FakeTestingEnum> .SerializeFn.Target); Assert.Equal(expectedDeserializeFunc.Target, JsConfigFnTargetResolver <FakeTestingEnum> .GetDeserializerTarget()); } }