How to Write Test Codes for C# ESS Projects

Release Date: 11/20/2019
Version: All

ESS (Elliott SPS Services) is a cloud hosting service that translates incoming EDI XML files  (i.e., 850) from SPS Commerce to the Elliott Sales Order Import format (fixed length ASCII), and translates the outgoing Elliott sales order export files (fixed length ASCII) to SPS Commerce EDI XML files (e.g., 810, 856, 855).

ESS is written in C#. The following document illustrates an example of how we write test codes for any feature we add for ESS. In this example, we added a partner config flag, DefaultOrerFrghtPayCode, to set the default value for ORDER_FRGHT_PAY_CODE.  The default is blank. But you can use this flag, for example, to set the default value of ORDER_FRGHT_PAY_CODE to "H" so the incoming sales order for a particular trading partner will be put on hold by default and require a "release" in Elliott in order to print the pick ticket.  See example codes below:



The codes above are very simple. But we do not just assume that it will work.  To make sure it will function as intended, we will write test codes to confirm. The test codes will be executed automatically upon the release of a new revision. The test codes must pass before the release process will push it to production. In addition, if there are any changes in other areas that somehow affect the result here, the test codes will catch those too. Therefore, this is a great QC process for source code changes and releases.

To write test codes for these few lines of code, we can right click on the source code area. In the popup menu, we choose, "Create Unit Test." See sample screen below:


In the popup dialog "Create Unit Tests," choose "xUnit.net 2.0" for Test Framework.  Choose "Ess.UnitTests" for Test Project.  Choose default for the rest.  See sample screen below:


If the test source file does not exist, it will be created automatically. In this case, the original source code file name is "HeaderFieldMapper.cs."  So the automatically created test codes file name will be "HeaderFieldMapperTests.cs." See sample screen below:


If the test source file already exists, that test source file will be brought up automatically.  You will then add your additional test logic to that source file.

The following is a sample implemented source code of the example feature. The function is descriptive to indicate the intention of the test. In this case, we wrote two functions: one to test when the partner config flag DefaultOrderFrghtPayCode = "H," and one to test when the flag is not set.  See sample screen below:


To run this test, you can move your cursor to the test function you just wrote and use the shortcut key Ctl-R, then Ctl-T to run the test for that function only. As you can see in the example following, only this test function was executed:


You can also test all written tests of this project by choosing "Run" -> "All Tests." See sample screen below.  This will take longer to run, but it will ensure the changes you made will not bring unintentional consequences to other areas:


EMK

Developer Documentations

  1. Received Code 9999 with Web Services Call
  2. Received Return Status Code 3 When Using Elilogin Login Method
  3. Elliott Web Service Requirements
  4. Elliott eStore Checklist
  5. LN API
  6. FN API
  7. RN API
  8. IN and DF API Change (V9.0)
  9. FA API Changes (V9.0)
  10. VA API Changes (V9.0)
  11. CartService
  12. EliarachService
  13. ElicshtxService
  14. EliattrbService
  15. ElisyscdService
  16. EliNoteService
  17. El2rstimService
  18. EliOrderService
  19. ItemInquiry
  20. EliitmiqService
  21. EliShiptoService
  22. El2getfrService
  23. Steps Required to Test ReportWriter in V8.2
  24. Installation of ElliottService, NETcellent’s Web Services for Elliott
  25. ResellerFinder
  26. EliaptrxService
  27. VendorInquiry
  28. EliloginService
  29. ElislsmnService
  30. EliserhsService
  31. EliatpobService
  32. ElievprcService
  33. ElihdtrxService
  34. ElicuswlService
  35. QueryTurnaround
  36. InvoiceInquiry
  37. ElicustmService
  38. EligetcdService
  39. OrderInquiry
  40. EliordiqService
  41. EliecontService
  42. EliautdpService
  43. El2CrCrdService
  44. Log-Timer / ElliottTimer.Ini Support
  45. Alpha Document Number Support (V8.5/V9.0)
  46. ElliottService System.TypeInitializationException
  47. Feature - Printing API to Dynamically Set Number of Copies
  48. The Values and Meanings of Distribution Types - ARDISFIL, APDISFIL, IMDISFIL, BMDISFIL
  49. DD API Changes (V9.0)
  50. PA API (8.5)
  51. Validate License API
  52. AP API
  53. TP API: Temporary Path
  54. Data Structures for Report Desk Defaults and Enforcements
  55. COBOL to VB Interface Programs
  56. IN API: Option to Support Files and Folders Validation
  57. FF API: File Functions
  58. ID API
  59. LK: Links API
  60. FFLNearYou
  61. Report Desk Developing and Debugging
  62. Developing a New Elliott V8.6 Report Desk User Defined Report (UDR)
  63. CustomerInquiry
  64. Elliott API (JSON Web Service)
  65. Animating COBOL Code in Elliott V8.5
  66. Preliminary Programming Changes for Elliott 8.6
  67. CV API
  68. System Lock File Requirements
  69. How to Write Test Codes for C# ESS Projects
  70. Solving the Inability to Debug Elliott on a New Server
  71. Report Desk: Developing Custom Reports
  72. Report Desk Tables
  73. Report Desk Database Delivery Strategy

Feedback and Knowledge Base