/Source/Bifrost.Specs/Serialization/for_Serializer/when_deserializing_type_with_an_interface_property_and_json_contains_type_reference.cs
# · C# · 22 lines · 17 code · 5 blank · 0 comment · 0 complexity · 0eb5ae8c3869343f5784a596f46fb08a MD5 · raw file
- using System;
- using Machine.Specifications;
-
- namespace Bifrost.Specs.Serialization.for_Serializer
- {
- public class when_deserializing_type_with_an_interface_property_and_json_contains_type_reference : given.a_serializer
- {
- const string json = "{\"Something\":{\"$type\":\"Bifrost.Specs.Serialization.for_Serializer.SomethingImplementation, Bifrost.Specs\",\"SomeValue\":\"Something\"}}";
-
- static ClassToSerialize instance;
-
- Establish context = () =>
- {
- container_mock.Setup(c => c.Get<ClassToSerialize>()).Returns(new ClassToSerialize());
- container_mock.Setup(c => c.Get(Moq.It.IsAny<Type>())).Returns((Type t) => Activator.CreateInstance(t));
- };
-
- Because of = () => instance = serializer.FromJson<ClassToSerialize>(json);
-
- It should_have_the_property_instance_set_to_instance_of_SomethingImplementation = () => instance.Something.ShouldBeOfType<SomethingImplementation>();
- }
- }