Print Page | Close Window

Unit Testing and XML serialization

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1689
Printed Date: 28-Mar-2025 at 10:37am


Topic: Unit Testing and XML serialization
Posted By: downeytim
Subject: Unit Testing and XML serialization
Date Posted: 16-Mar-2010 at 6:11am
Is there any way to create an XML file that contains entities to be used to load the EntityManager with and run unit tests.  We want to create a "mock" situation where we can run unit tests without have a DB present.  We want to create an XML file that contains the data for the tests, load it into a disconnected EntityManager, run our tests and check the results.



Replies:
Posted By: downeytim
Date Posted: 16-Mar-2010 at 11:45am
Some additonal data on this.
 
I have been able to serialize OUT to XML an instance of one of my Entity based classes.  But the Deserialization fails with a Null Object Reference.  Below is the exception. It looks like it is failing trying to find the EntityGroup for the object being created.  Yet where was no group when it was serialized.  It was created in code without an entity manager or group
 
IdeaBlade.EntityModel.EntityWrapper.get_EntityGroup()
IdeaBlade.EntityModel.EntityWrapper.get_EntityManager()
IdeaBlade.EntityModel.EntityWrapper.get_VerifierEngine()
SetValueWithVerification(DataEntityPropertySetInterceptorArgs`2 setterArgs)
b__4(DataEntityPropertySetInterceptorArgs`2 args)
HandleAction(Action`1 action, TArgs args)
b__3(TArgs args)
ExecuteActions(TArgs args)
SetValue(TInstance instance, Object context, TValue value)
SetValue(TInstance instance, TValue value)
SetValue(TInstance instance, TValue value)
CSS.Data.Test.TestClass.set_Name(String value) in C:\Dev\Cypress\Cypress.Framework\Main\CSS.Data\CSS.Data.Test\UnitTest1.cs: line 281
ReadTestClassFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract)
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)
CSS.Data.Test.UnitTest1.DeserializeBusObject[T](String filename, T& entity) in C:\Dev\Cypress\Cypress.Framework\Main\CSS.Data\CSS.Data.Test\UnitTest1.cs: line 211
CSS.Data.Test.UnitTest1.LoadTestClassFromXmlTest() in C:\Dev\Cypress\Cypress.Framework\Main\CSS.Data\CSS.Data.Test\UnitTest1.cs: line 186



Print Page | Close Window