public void Add() { var storage = new ObjectSerializerStorage(); var serializer = new MockSerializer(typeof(MockDerived)); storage.Add(serializer); Assert.IsTrue(storage.HasSerializerFor(typeof(MockDerived))); Assert.IsTrue(storage.HasSerializerFor(typeof(MockMoreDerived))); Assert.IsFalse(storage.HasSerializerFor(typeof(MockBase))); Assert.IsFalse(storage.HasSerializerFor(typeof(IMockBase))); Assert.IsFalse(storage.HasSerializerFor(typeof(IMockDerived))); Assert.AreSame(serializer, storage.SerializerFor(typeof(MockDerived))); Assert.AreSame(serializer, storage.SerializerFor(typeof(MockMoreDerived))); }
public void AddClassSerializerWithMoreDerivedClassSerializersExisting() { var storage = new ObjectSerializerStorage(); var derivedSerializer = new MockSerializer(typeof(MockDerived)); storage.Add(derivedSerializer); var baseSerializer = new MockSerializer(typeof(MockBase)); storage.Add(baseSerializer); Assert.IsTrue(storage.HasSerializerFor(typeof(MockDerived))); Assert.IsTrue(storage.HasSerializerFor(typeof(MockMoreDerived))); Assert.IsTrue(storage.HasSerializerFor(typeof(MockBase))); Assert.IsFalse(storage.HasSerializerFor(typeof(IMockBase))); Assert.IsFalse(storage.HasSerializerFor(typeof(IMockDerived))); Assert.AreSame(baseSerializer, storage.SerializerFor(typeof(MockBase))); Assert.AreSame(derivedSerializer, storage.SerializerFor(typeof(MockDerived))); Assert.AreSame(derivedSerializer, storage.SerializerFor(typeof(MockMoreDerived))); }