npg-opsdev/agent-orders — pull request #1 by hamidz (2012-09-05 01:13:57+00:00)
Title: agent-orders

Hello Mr Gerald
actually it took more than the 30m that the test was supposed to take for one reason, beside of the error already existing on the code,
when i ran the project using visual studio 2012 web development i had an exception thrown saying that the library (OrderImport.dll) could`t
be loaded.

After a while i had to recreate the solution you provided and put on one file just for test matter, and it worked well (attached to this email) .

Now i had to deal with the problem you wanted to be resolved at the origin , so this is how i proceeded.

I checked the c# code first very quickly and seemed to be OK after that the aspx file, which was fine too; this being done I was able to run the project.

I tried the xml files included in the solution , the first one worked well but the second caused an exception to be thrown (as it was mentioned in the test description) during the parsing .
I went to the line 24 of the file (it was shown on the exception message.)

The exception was caused by the using of the character "&" which is not allowed in XML and was fixed by replacing it by the
predefined entity "&" instead to display it ; so I changed it and it worked very well .
It took me actually 20sec to find the cause of the exception.
now we need to find a better solution than changing these character manually especially when we have a massive amount of data and files to deal with.

The first solution that came to my mind was to impose some validation rules or replacing these entity references by their valid equivalences when entering the data at the first place , but understanding that we may have to use XML files coming from different origins and sources this solution was no longer one to our problem.

Within different options, i have chosen to work with regular expressions.
We will look up for any "&" character (not followed by "amp;", "apos;", "quot;", "lt;" or "gt;") and replace it by "&" , we can do the same job with the other unwelcome characters (',",<,>).
What makes this solution suitable is the limited number of entity references in XML compared to the more than 250 existing in HTML.

NB : (it may be coming from the visual studio version i`m using )
I didn't use this project to test the solution since i encountered some other problems trying to run it.
--- Missing DLL file (nunit.framework.dll) from the tests folder.
--- I had this exception "Could not load file or assembly 'OrderImport' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."

Reason why i put all project (classes and methods) in 1 file and ran it and it worked well i attached this solution and the one you provided

Thank you very much
Best regards.