DOC

BizTalk Test Object Model Design

By Jerome Hunt,2014-08-27 16:39
11 views 0
BizTalk Test Object Model Design

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 1 of 21

    Design Doc: BizTalk Test Object Model

    Doc Name BizTalk Test Object Model Design.doc

    Doc Status DRAFT

    Doc Milestone PathFinder

    Author MrinalB

Abstract

    This document describes the design for BizTalk Test Object Model.

Contents

    1. Introduction .............................................................................................................................. 1

    2. Functional Design ....................................................................................................................... 2

    3. AL Interface Descriptions .......................................................................................................... 12

    4. IL Class Descriptions ................................................................................................................ 13

    5. Test Classes ............................................................................................................................ 13

    6. Coding Best Practices ............................................................................................................... 18

    7. Usage Best Practices ................................................................................................................. 21

    8. Open Issues ............................................................................................................................ 21

    1. Introduction

    This document describes the object model design for BizTalk Test Objects. The main focus is describing a model which allows maximum code reuse and ease of maintenance.

    1.1. Requirements

    Here are some of the high level design goals

    1) Ability to write Test cases in a programming language to leverage development tools

    2) Leveraging design time experience of VS tools such as intelli-sense and compile-

    time verification

    3) Avoid duplication of test effort by providing common and extensible framework across

    team

    4) Test case transparency to product features - I.e. Interfaces exposed to test cases

    should be abstracted to facilitate easy maintenance when the underlying

    implementation class changes. With the flip of change at test Suite/Case level,

    underlying implementation classes can be switched.

    5) Ability to test for backward compatibility of product interfaces

    6) Compact Object model and few binaries to reduce the test setup time

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 2 of 21

    7) Ability to write multi machine tests using the same object model

    8) Ability to have parallel/concurrent test execution

    9) Minimal or no dependencies with existing Test Framework/Executor model - Idea is to

    package these for vendors to be able to write tests and also for Developers to write

    unit tests

    10) Minimal dependency on Test Harness

    11) Leveraging the design and implementation work that went into WinOE Test Object

    model design

    12) Test cases to leverage the Context information independent of test harness and test

    case manager and ability to pass context information across machines

    13) Ease of writing test cases. We need to abstract the complexity of the product

    interfaces away from the test writer.

    14) Object-oriented organization of often-used test entities.

    2. Functional Design

    A well-known design pattern which addresses these issues and solves this problem is the Bridge pattern (Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1995).

    2.1. High Level Design

    The test design consists of two parallel hierarchies: Platform Abstraction Hierarchy (PAH)

    and Test Abstraction Hierarchy (TAH).

    THIS DIAGRAM ILLUSTRATES THE PATTERN OF USAGEIt’s not supposed to be exhaustiveTEST OBJECT HIERARCHYPLATFORM ABSTRACTION HIERARCHY

    BTSConfigBase

    E2EScenarioIAdminUtilAdaptor

    RoleSendPort

    Party

    RecvPortOrchestration

    PipelineAssemblyWMIAdminUtilExpOMAdminUtil

    ?The Test Objects (entities) are the building blocks that can be used to build composite test objects that will represent test scenarios. For example, an E2EScenario object will have a collection of Servers, Orchestrations, SendPorts, RecvPorts, ?We use the Platform Abstraction interfaces to abstract all the Pipelines, Roles, Parties etc.product functionality and implementation from the Test Objects ?When looking for these entities, we need to look from the test (entities).perspective and not try to replicate the product object hierarchy. ?The Test Objects call the Class Factory to get the abstraction This will allow us to keep the model simple.interfaces that they can use to get the product functionality.?Having a Base Class (e.g. BTSConfigBase) with a set of essential abstract methods (Create(), Delete(), etc) will allow us to take advantage of polymorphism for the collections of Test Entities.?All the entities use the Platform Abstraction interfaces for product related actions.

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 3 of 21

    Platform Abstraction Hierarchy (PAH): This layer takes care of abstracting the product

    functionality and other common functionality while allowing the implementation to vary. It

    achieves it through an Abstraction Layer (AL) and an Implementation Layer (IL).

    Abstraction Layer (AL): The Abstraction Layer consists of a Class Factory and a set

    of Abstract Interfaces.

    ? Class Factory: The Class Factory creates instances of relevant implementation

    layer objects based on the test-context and casts them to relevant interfaces

    thus abstracting the implementation class. It consists of a set of static

    methods that return interface references. These interfaces abstract the

    concrete classes that implement the interface, thus reducing the maintenance

    cost associated with changing test code when the implementation class

    changes.

    ? Abstract Interfaces: These interfaces are designed to provide Action-based

    methods for platform actions.

    Implementation Layer (IL): The Implementation Layer consists of concrete classes.

    These classes implement AL interfaces to implement product functionality as well as

    some common functionality used across the team. One AL interface can be

    implemented by more than one concrete class. For example, the IAdmin interface can

    be implemented by both an WMIAdmin class as well as an ExpOMAdmin class using

    WMI and ExplorerOM respectively to expose the same product functionality. Also, one

    class can implement more than one interface. It’s advisable that the classes in this

    layer not be instantiated directly but always through the Class Factory.

    THIS DIAGRAM ILLUSTRATES THE PATTERN OF USAGEIt’s not supposed to be exhaustive

    TEST OBJECTSTEST CASES

    ?Abstraction Layer has interfaces with action-based methods.CLASS FACTORY?A Class Factory creates instances of relevant objects and casts them to relevant interfaces IVSCompilerUtilIXSCompilerUtilbefore returning thus abstracting ABSTRACTION the implementation.LAYERIAdminUtilICompilerUtil?By this design test cases/objects need not be changed when the underlying implementation class changes because tests only make method calls on an interfaces.

    ?Implementation layer classes implement Abstraction Layer interfaces plus other useful methods.ExpAdminUtilWMIAdminUtil?One class can implement more IMPLEMENTATION than one interface.VSCompilerUtilXSCompilerUtilLAYER?It’s advised that the classes in this layer not be instantiated directly but always through the Class Factory.

    PRODUCT SURFACEOTHER APPS

    OS

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 4 of 21

    Test Object Hierarchy (TOH): The Test Object Hierarchy is meant to organize the BizTalk related test entities in an object-oriented fashion to facilitate their reuse and ease of maintenance. TOH is made up of three different kinds of test objects:

    Building Block Test Classes: These are the atomic building blocks that encapsulate

    the basic test entities (data and methods). The methods in these classes use the

    interfaces from the PAH to execute platform-related code (product code and other

    common code).

    Group Base Test Classes: The Building Block Objects are easy to categorize into

    groups based on their usage. The common methods and data from such a group then

    can be factored out into a base class for polymorphic use.

    Composite Test Classes: The Building Block classes can be assembled in different

    ways and numbers to reflect the real test scenarios. These commonly used Composite

    Test Classes make more sense from the test-writer’s perspective for scenario based

    testing.

    THIS DIAGRAM ILLUSTRATES THE PATTERN OF USAGE

    It’s not supposed to be exhaustive

    BTSConfigBase

    + Create()Composite Test Group Base ClassClass+ Delete()

    OrchestrationE2EScenarioAdaptor

    RoleSendPortBuilding Block

    ClassesParty

    RecvPort

    PipelineAssembly

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 5 of 21

    2.2. Small Proof of Concept

    The following is a small proof of concept containing the following:

    an IAdmin interface with only two methods called CreateHost and Delete (These

    methods do nothing but print some trace; bear with me for demostration sake),

    two IL classes that implement the IAdmin (called Admin1 and Admin2),

    the Class Factory that instantiates these classes based on test-context,

    the class that provides context related services, called TestContextBag,

    the test class called Host that makes use of the IAdmin interface inside it’s create

    method.

    This sample tries to describe how the pieces come together in this design. The comments included describe most of what is happening.

    Consider the following code:

////////////////////////////////////////////////////////////////////////////////////////////////////

    //The interface definition for IAdmin

    using System;

    namespace Microsoft.BizTalk.Test.Abstraction

    {

     public interface IAdmin

     {

     void CreateHost(string Name,

     string Type,

     string WindowsGroup,

     bool HostTracking,

     bool AuthTrusted,

     bool IsDefaultInGrp

     );

     void DeleteHost(string Name);

    }

    /////////////////////////////////////////////////////////////////////// //The two IL classes with implementation (these classes just write some trace out)

using System;

    using Abs = Microsoft.BizTalk.Test.Abstraction;

    using Microsoft.WinOE.Test.TestCases;

    using System.Diagnostics;

namespace Microsoft.BizTalk.Test.TestObjects

    {

     public class WMIAdmin: IAdmin

     {

     public WMIAdmin()

     {

     }

     public void CreateHost(string Name,

     string Type,

     string WindowsGroup,

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 6 of 21

     bool HostTracking,

     bool AuthTrusted,

     bool IsDefaultInGrp)

     {

     //This is just for demo right now

     System.Diagnostics.Trace.WriteLine("WMIAdmin.CreateHost() was

    called", TestCaseLogCategory.Info);

     }

     public void DeleteHost(string Name)

     {

     //This is just for demo right now

     System.Diagnostics.Trace.WriteLine("WMIAdmin.DeleteHost() was

    called", TestCaseLogCategory.Info);

     }

     }

     public class ExpOMAdmin: IAdmin

     {

     public ExpOMAdmin()

     {

     }

     public void CreateHost(string Name,

     string Type,

     string WindowsGroup,

     bool HostTracking,

     bool AuthTrusted,

     bool IsDefaultInGrp)

     {

     //This is just for demo right now

     System.Diagnostics.Trace.WriteLine("ExpOMAdmin.CreateHost() was

    called", TestCaseLogCategory.Info);

     }

     public void DeleteHost(string Name)

     {

     //This is just for demo right now

     System.Diagnostics.Trace.WriteLine("ExpOMAdmin.DeleteHost() was

    called", TestCaseLogCategory.Info);

     }

     }

    }

//////////////////////////////////////////////////////////////////

    //The Class Factory: Notice how it uses the context to return the

    // proper object

    using System;

    using Microsoft.BizTalk.Test.Commom;

    using Microsoft.BizTalk.Test.TestObjects;

    namespace Microsoft.BizTalk.Test.Abstraction {

     ///

     /// A collection of static methods used to create the implementation

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 7 of 21

     /// classes and cast the the reference to the corresponding

    interface

     /// and return the interface reference

     /// series of objects.

     ///

     public class ClassFactory

     {

     ///

     /// Default constructor made private so that no

     /// instances of this class are created.

     ///

     private ClassFactory()

     {

     }

     ///

     /// Creates a Admin class.

     ///

     /// An IAdmin interface

     public static IAdmin CreateAdmin()

     {

     string AdminMode = TestContextBag.WhichAdminToUse;

     switch (AdminMode)

     {

     case "WMIAdmin":

     return new WMIAdmin();

     case "ExpOMAdmin":

     return new ExpOMAdmin ();

     default:

     return new WMIAdmin();

     }

     }

     }

    }

//////////////////////////////////////////////////////////////////////

    //TestContextBag: The class that provides the context-related services

    using System;

    using System.Threading;

    using System.Collections;

    using System.Runtime.Remoting.Messaging;

    namespace Microsoft.BizTalk.Test.Commom {

     ///

     /// Implements test context and TLS parameter accessor.

     ///

     public class TestContextBag

     {

     ///

     /// Gets or sets a creation mode.

     ///

     public static string WhichAdminToUse

     {

     get { return (string)GetParameter("WhichAdminToUse",

    DefaultAdmin); }

     set { SetParameter("WhichAdminToUse", value); }

     }

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 8 of 21

     #region Private Members

     ///

     /// Gets the property value from context or TLS.

     ///

     /// Parameter name

     /// Parameter value

     private static string GetParameter(string name)

     {

     if (null == name)

     throw new ArgumentNullException("name");

     string value = null;

     // Try to get a value from context dictionary first.

    Dictionary is itself stored in

     // call context.

     Hashtable context =

    (Hashtable)CallContext.GetData(ContextDictionary);

     if (context != null)

     {

     value = (string) context[name];

     }

     // Value is not in context variable or slot is not

    available, try to get

     // it from TLS

     if (null == value)

     {

     LocalDataStoreSlot slot =

    Thread.GetNamedDataSlot(name);

     if (slot != null)

     {

     value = (string) Thread.GetData(slot);

     }

     }

     return value;

     }

     ///

     /// Gets the property value from context or TLS. Default

    parameter value is used if no value is available.

     ///

     /// Parameter name

     /// Default parameter value

     /// Parameter value

     private static object GetParameter(string name, object defaultValue)

     {

     object value = GetParameter(name);

     if (null == value)

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 9 of 21

     value = defaultValue;

     return value;

     }

     ///

     /// Sets the property value to the TLS.

     ///

     /// Parameter name

     /// Parameter value

     private static void SetParameter(string name, object value)

     {

     if (null == name)

     throw new ArgumentNullException("name");

     Hashtable localTable =

    (Hashtable)CallContext.GetData(ContextDictionary);

     localTable[name] = value;

     }

     #endregion

     #region Parameter Names and Default Values

     private const string ContextDictionary = "ContextDictionary";

     private const string DefaultAdmin = "Admin1";

     #endregion

     }

    }

//////////////////////////////////////////////////////////////////////

//The TestAdminBase class

    public abstract class TestAdminBase

     {

     public abstract void Create();

     public abstract void Delete();

     }

//////////////////////////////////////////////////////////////////////

//The Host class that derives from TestAdminBase and makes use of the

    //IAdmin interface

public class Host : TestAdminBase

     {

     string _Name;

     string _Type;

     string _WindowsGroup;

     bool _HostTracking;

     bool _AuthTrusted;

     bool _IsDefaultInGrp;

     IAdmin _Admin;

     public Host(string Name,

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

    错误?使用“开始”选项卡将 Title 应用于要在此处显示的文字。 Page 10 of 21

     string Type,

     string WindowsGroup,

     bool HostTracking,

     bool AuthTrusted,

     bool IsDefaultInGrp)

     {

     _Name = Name;

     _Type = Type;

     _WindowsGroup = WindowsGroup;

     _HostTracking = HostTracking;

     _AuthTrusted = AuthTrusted;

     _IsDefaultInGrp = IsDefaultInGrp;

     _Admin = ClassFactory.CreateAdmin();

     }

     public Host(string Name,

     string Type,

     string WindowsGroup,

     bool HostTracking,

     bool AuthTrusted,

     bool IsDefaultInGrp,

     IAdmin Admin)

     {

     _Name = Name;

     _Type = Type;

     _WindowsGroup = WindowsGroup;

     _HostTracking = HostTracking;

     _AuthTrusted = AuthTrusted;

     _IsDefaultInGrp = IsDefaultInGrp;

     _Admin = Admin;

     }

     public override void Create()

     {

     _Admin.CreateHost(_Name, _Type, _WindowsGroup,

    _HostTracking, _AuthTrusted, _IsDefaultInGrp);

     }

     public override void Delete()

     {

     _Admin.DeleteHost(_Name);

     }

     }

//////////////////////////////////////////////////////////////////////

    //The test case that makes use of the design using System;

    using System.Diagnostics;

    using Microsoft.WinOE.Test.TestCases; using Microsoft.BizTalk.Test.Abstraction; using Microsoft.BizTalk.Test.Commom; using Microsoft.BizTalk.Test.TestObjects; using System.Collections;

[assembly : AssemblyDriver]

    namespace PKMTestCase//Enter your namespace {

    Microsoft Confidential. Copyright ? 2003 Microsoft Corporation.

Report this document

For any questions or suggestions please email
cust-service@docsford.com