In today’s discussion, we will talk about writing Unit Tests, but it is not about how to get started with Unit Tests. Rather it is about, if you have a scenario where in you need to construct data set which is very primitive and it needs lot of work to construct even mock data. So, the best thing which I found is you can collect the actual data either from SOAP tool, if it is some kind service response and have the same in XML. And then you can write Unit Tests against that as in the following.
For one of the scenarios I have collected and constructed my XML as in the following code snippet.
- <?xml version="1.0" encoding="utf-8" ?>
- <CustomerResponseDTO>
- <ContractList>
- <Contract>
- <ContractNumber>530000000112</ContractNumber>
- <ContractIdPK>713343129248515901</ContractIdPK>
- <CurrencyType>1000001</CurrencyType>
- <CurrencyValue>USD</CurrencyValue>
- <FrequencyModeValue>B</FrequencyModeValue>
- <BillingValue>10 Days Inv</BillingValue>
- <ServiceProvId>1</ServiceProvId>
- <CompanyNumber>19</CompanyNumber>
- <IssueLocation>US</IssueLocation>
- <ContractLastUpdateDate>2015-05-10 16:14:45.158</ContractLastUpdateDate>
- <ContractLastUpdateUser>mdmadmin</ContractLastUpdateUser>
- <ContractLastUpdateTxId>626143129248478201</ContractLastUpdateTxId>
- <AgreementName>MaxWell</AgreementName>
- <ComponentID>1000944</ComponentID>
- <ContractExtension>
- <CreditLimit>222</CreditLimit>
- <ShippingChargeFlag>Y</ShippingChargeFlag>
- <TaxableFlag>Y</TaxableFlag>
- <CustomerClass>SA</CustomerClass>
- <CreatedBy>DSA</CreatedBy>
- <LinkNumDesc>Test</LinkNumDesc>
- <SalesPerson/>
- <ModifyBy>XMODIFY_BY</ModifyBy>
- </ContractExtension>
- <AdminNativeKey>
- <AdminNativeKey>
- <adminNativeKeyIdPK>712243</adminNativeKeyIdPK>
- <adminContractId>530000</adminContractId>
- <adminFieldNameType>CustomerAccountNumber</adminFieldNameType>
- <adminFieldNameValue>123456</adminFieldNameValue>
- <contractId>7133431</contractId>
- <nativeKeyLastUpdateDate>2015-05-10 16:14:45.266</nativeKeyLastUpdateDate>
- <nativeKeyLastUpdateUser>mdmadmin</nativeKeyLastUpdateUser>
- <nativeKeyLastUpdateTxId>6261431</nativeKeyLastUpdateTxId>
- </AdminNativeKey>
- </AdminNativeKey>
- </Contract>
- </ContractList>
- </CustomerResponseDTO>


Join the conversation! Your thoughts help the community grow.