From: Owen R. <exo...@us...> - 2005-09-08 01:07:56
|
Update of /cvsroot/netreflector/NetReflector/src/NetReflector.Test/Attributes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10450/src/NetReflector.Test/Attributes Added Files: ReflectorPropertyTest.cs Log Message: NETREF-5: adding support for customisable serialisation. attributes use DefaultSerialiserFactory by default -- however clients can override for more control over serialisation process. --- NEW FILE: ReflectorPropertyTest.cs --- using Exortech.NetReflector.Util; using NMock; using NMock.Constraints; using NUnit.Framework; namespace Exortech.NetReflector.Test.Attributes { [TestFixture] public class ReflectorPropertyTest { private ReflectorPropertyAttribute attribute; private ReflectorMember member; [SetUp] protected void SetUp() { attribute = new ReflectorPropertyAttribute("foo"); member = ReflectorMember.Create(typeof (TestClass).GetProperty("Name")); } [Test] public void ShouldUseCustomSerialiserFactory() { IMock mockSerialiser = new DynamicMock(typeof (IXmlMemberSerialiser)); IMock mockFactory = new DynamicMock(typeof (ISerialiserFactory)); mockFactory.ExpectAndReturn("Create", mockSerialiser.MockInstance, new IsTypeOf(typeof (ReflectorMember)), attribute); attribute.SerialiserFactory = (ISerialiserFactory) mockFactory.MockInstance; attribute.CreateSerialiser(member); mockFactory.Verify(); } [Test] public void ShouldUseDefaultSerialiserFactory() { ReflectorPropertyAttribute attribute = new ReflectorPropertyAttribute("foo"); IXmlSerialiser serialiser = attribute.CreateSerialiser(member); Assert.IsNotNull(serialiser); } } } |