XMLBasic error in testing but not in application


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
That makes sense.  You can use a different mecahnism to provide the version to prevent this error.  We actually have a shared class with constants for version for this type of thing so as to prevent these types of errors.  That me be an idea to prevent this from happening since there is not an entry assembly.  I am sure that if you us the executing assemby it would work, but you might still want to use a constant instead.
Chan
Chan
Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have found out the cause. It is because I called OpenXMLFile(TableName, PathAndFileName, ColumnStructure), which internally retrieve currentversion using code System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(). In unit test environment, this code always return nothing.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Obviously this is going to be really hard for me to diagnose over this post.  I do not have much experience with nUnit;  however, we do use unit testing through Team Foundation...however, I do not think that we have a test setup pulling from an XML file.  So I cannot give you a 100%, "I know this works" answer.  But it does seem suspect.  The OpenXmlFile is a shared or static method...so I wonder if the AppDomain has not been properly established at the point of execution.

The first thing I would do is determine which object or reference is producing the NullReferenceException.  Then it might give you/us a clue as to where to look to come up with a solution.

Chan
Chan
Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)Advanced StrataFrame User (713 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I hit error below when I run it from NUnit. However, it is working fine if I run it from my windows application. Any ideas?



[Test]

public void TestPlugInInfosBOFillAll()

{

PlugInInfosBO loPlugInInfosBO = new PlugInInfosBO();

loPlugInInfosBO.FillAll();



Assert.AreEqual(2, loPlugInInfosBO.Count);

}



Error   29   TestCase 'TestPlugIn.TestPlugInInfosBOFillAll' failed: Object reference not set to an instance of an object.

System.NullReferenceException

Message: Object reference not set to an instance of an object.

Source: MicroFour StrataFrame Base

StackTrace:

at MicroFour.StrataFrame.Xml.XmlBasics.OpenXmlFile(String TableName, String PathAndFileName, List`1 ColumnStructure)

at JK.Framework.Business.XMLBusinessLayer.FillAll() in F:\Projects\JKFramework\JK Framework Business\Business\XMLBusinessLayer.cs:line 98

at TestPlugIn.TestPlugIn.TestPlugInInfosBOFillAll() in F:\Projects\JKFramework\Test\TestPlugIn\TestPlugIn\TestPlugIn.cs:line 135   F:\Projects\JKFramework\JK Framework Business\Business\XMLBusinessLayer.cs   98   

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search