How to Write Test Codes for C# ESS Projects

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



    • Related Articles

    • Feature – Import Shopify Orders to Elliott through ESS and SPS

      Release Date: 07/08/2023 Version: 8.5 & Up New Features to Support Shopify Interface Shopify is a popular turnkey solution for creating eCommerce websites. Our EDI partner has created an interface with Shopify so the eCommerce order can be imported ...
    • Disk Write Back Latency Issue with AWS Servers

      Release Date: 02/10/2022 Version: All For the past two-plus years, Netcellent has migrated all of its in-house servers to AWS (Amazon Web Services). We also help some of our customers in implementing their servers on AWS. We can advise you that ...
    • Btrieve Error Codes 001 - 199

      MicroKernel (Btrieve) Database Engine Status Codes This section describes status codes that the MicroKernel returns. All status codes are provided in 3-digit formats since the search on this website cannot search 1 or 2-digit words correctly. That is ...
    • Installation of ElliottService, NETcellent’s Web Services for Elliott

      Installation to New Server 1. Server Location: Decide if you are going to install the web services on the same machine running Elliott, or a separate server on your network. The machine must reside on your network. 2. Set Up Server: If your ...
    • SPS Document Processing Error on AllowChrgAmt

      Release: 12/31/2019 Updated: 7/10/23 Version: All Q - I received an email from SPS Commerce showing this message: InvoiceNumber:708241 InvoiceNumber:708241 Missing element: expect AllowChrgAmt before ending ChargesAllowances in line 106,column 25 ...