Tuesday, 29 January 2013

Unit Testing Biztalk 2010 Artifacts using BizUnit 4.0


Testing XML Schema.

Step 1:Create Schema.Xsd


 











Step 2: 


Create Instance of Schema.Xsd
<ns0:Employee xmlns:ns0="http://Company.Demo.Schemas.Employee">
  <FirstName>Kumar</FirstName>
  <LastName>Janssen</LastName>
  <SocialSecurityNumber>330409710</SocialSecurityNumber>
  <Type>Full</Type>
  <Function>Manager</Function>
  <Salary>50000</Salary>
  <Bonus>1000</Bonus>
  <Pension>1000000</Pension>
</ns0:Employee>

Step 3:



Bizunit Method for testing Instance.xml

  [TestMethod]
        public void TestEmployeeSchema()
        {
            var employeeTest = new TestCase { Name = "Test Schema.Xsd Schema" };

            //Create the file validate step
            var validatingFileReadStep = new FileReadMultipleStep
            {
                DirectoryPath = @"..\..\..\Company.Demo\Company.Demo.Sample.Schemas",
                SearchPattern = "Instance.xml",
                ExpectedNumberOfFiles = 1,
                Timeout = 3000,
                DeleteFiles = false
            };

            //Create an XML Validation step
            //This will check the result against the XSD for the Employee document
            var validation = new XmlValidationStep();
            var employeeSchema = new SchemaDefinition
            {
                XmlSchemaPath =
                @"..\..\..\Company.Demo\Company.Demo.Schemas\Sample.xsd",
                XmlSchemaNameSpace = "http://Company.Demo.Schemas.Employee"
            };
            validation.XmlSchemas.Add(employeeSchema);

            validatingFileReadStep.SubSteps.Add(validation);

            employeeTest.ExecutionSteps.Add(validatingFileReadStep);

            //Execute Tests
            var bizUnit = new BizUnit.BizUnit(employeeContractTest);
            bizUnit.RunTest();
        }

4 comments:

  1. could you please provide similar similar code for flat file validation as well? i tried a lot with multiple options but not getting any where

    ReplyDelete
  2. Enable unit testing of Biztalk Project , then try code

    TestableSchemaBase _Schema = new SchemaName();
    bool result = _Schema.ValidateInstance(@"FilePath", OutputInstanceType.XML);
    Assert.IsTrue(result, "Validation Failed");

    TestableSchemaBase _Schema = new SchemaName_FF();
    bool result = _Schema.ValidateInstance(@"TextFilePath", OutputInstanceType.Native);
    Assert.IsTrue(result, "Validation Failed");

    ReplyDelete
  3. Biztalk server online training - 21st Century Software Solutions
    http://www.21cssindia.com/courses/biztalk-server-online-training-213.html
    ఈ పేజీని అనువదించు
    biztalk server online training, biztalk server training, biztalk server online training visakhapatnam, biztalk 2010 online training, microsoft biztalk online training, ...
    Biztalk admin online training - 21st Century Software Solutions
    http://www.21cssindia.com/courses/biztalk-admin-online-training-220.html
    ఈ పేజీని అనువదించు
    biztalk admin online training, biztalk admin training, biztalk server online training, biztalk server training, biztalk admin course contents, biztalk admin enquiry, .Courses at 21st Century Software Solutions
    Talend Online Training -Hyperion Online Training - IBM Unica Online Training -
    Siteminder Online Training - SharePoint Online Training - Informatica Online Training
    SalesForce Online Training - Many more… | Call Us +917386622889
    Visit: http://www.21cssindia.com/courses.html

    ReplyDelete
  4. Biztalk Server Online Training, ONLINE TRAINING – IT SUPPORT – CORPORATE TRAINING http://www.21cssindia.com/courses/biztalk-server-online-training-213.html The 21st Century Software Solutions of India offers one of the Largest conglomerations of Software Training, IT Support, Corporate Training institute in India - +919000444287 - +917386622889 - Visakhapatnam,Hyderabad Biztalk Server Online Training, Biztalk Server Training, Biztalk Server, Biztalk Server Online Training| Biztalk Server Training| Biztalk Server| "Courses at 21st Century Software Solutions
    Talend Online Training -Hyperion Online Training - IBM Unica Online Training - Siteminder Online Training - SharePoint Online Training - Informatica Online Training - SalesForce Online Training - Many more… | Call Us +917386622889 - +919000444287 - contact@21cssindia.com
    Visit: http://www.21cssindia.com/courses.html"

    ReplyDelete