protected override void Given() { session = Substitute.For<ISerializationSession>(); var backingStore = Substitute.For<IBackingStore>(); var registry = new Registry(backingStore); registry.RegisterGraph<IsolatedClass>(); registry.RegisterGraph<ComposingClass>(); subject = new JsonSerializer<ComposingClass>((IRegisteredGraph<ComposingClass>)registry.RegisteredGraphs[typeof(ComposingClass)]); isolatedGraph = new IsolatedClass {AProperty = "test property"}; composingGraph = new ComposingClass {AnotherProperty = "another property", Composed = isolatedGraph}; expectedInternalId = new InternalId(Guid.NewGuid()); session.InternalIdOfTrackedGraph(isolatedGraph).Returns(expectedInternalId); }
protected override void Given() { session = Substitute.For<ISerializationSession>(); var backingStore = Substitute.For<IBackingStore>(); var registry = new Registry(backingStore); registry.RegisterGraph<IsolatedClass>(); registry.RegisterGraph<ComposingClass>(); subject = new JsonSerializer<ComposingClass>((IRegisteredGraph<ComposingClass>)registry.RegisteredGraphs[typeof(ComposingClass)]); expectedInternalId = new InternalId(Guid.NewGuid()); jsonSource = @"{""Composed"":{""__StashInternalId"":""" + expectedInternalId + @"""},""AnotherProperty"":""another property""}"; serialised = new PreservedMemoryStream(); using(var sw = new StreamWriter(serialised)) sw.Write(jsonSource); expected = new IsolatedClass(); session.TrackedGraphForInternalId(expectedInternalId).Returns(expected); }