XMLBasic error in testing but not in application


Author
Message
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 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   

Replies
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 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 (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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.
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