PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 1using System;
 2using Machine.Specifications;
 3
 4namespace Bifrost.Specs.Serialization.for_Serializer
 5{
 6    public class when_deserializing_type_with_an_interface_property_and_json_contains_type_reference : given.a_serializer
 7    {
 8        const string json = "{\"Something\":{\"$type\":\"Bifrost.Specs.Serialization.for_Serializer.SomethingImplementation, Bifrost.Specs\",\"SomeValue\":\"Something\"}}";
 9
10        static ClassToSerialize instance;
11
12    	Establish context = () =>
13    	                    	{
14    	                    		container_mock.Setup(c => c.Get<ClassToSerialize>()).Returns(new ClassToSerialize());
15    	                    		container_mock.Setup(c => c.Get(Moq.It.IsAny<Type>())).Returns((Type t) => Activator.CreateInstance(t));
16    	                    	};
17
18    	Because of = () => instance = serializer.FromJson<ClassToSerialize>(json);
19
20        It should_have_the_property_instance_set_to_instance_of_SomethingImplementation = () => instance.Something.ShouldBeOfType<SomethingImplementation>();
21    }
22}