From: Chris M. <cm...@us...> - 2007-01-10 22:56:52
|
User: cmicali Date: 07/01/10 14:56:53 Added: etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests AndroMDA.ScenarioUnit.Tests.csproj App.config TestDerivedObject.cs TestException.cs TestObject.cs TestScenarioHelperTests.cs etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/Properties AssemblyInfo.cs etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/actual_output/TestScenarioHelperTests Placeholder.txt etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests GetMultipleTestObjects_MultipleReturnParameters.xml GetMultipleTestObjects_MultipleReturnParameters_derivedChildObj.xml GetTestObjectCollection_CollectionParameters.xml GetTestObjectList_ListParameter.xml GetTestObjectWithId_PrimitiveInputParameter.xml GetTestObject_NoInputParameter.xml ProcessMixedAsserters_CodeAssertionFailure.xml ProcessMixedAsserters_XMLAssertionFailure.xml ProcessMixedAsserters_default.xml ProcessMultipleTestObjects_MultipleInputParameters.xml ProcessTestObject_NoIgnoreRules.xml ProcessTestObject_NoRulesFile.xml ProcessTestObject_default.xml etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests GetMultipleTestObjects_MultipleReturnParameters_parentObj.xml GetTestObjectCollection_CollectionParameters_ids.xml GetTestObjectList_ListParameter_ids.xml GetTestObjectWithId_PrimitiveInputParameter_id.xml ProcessMixedDataProviders_default_testObject.xml ProcessMultipleTestObjects_MultipleInputParameters_baseChildObj.xml ProcessMultipleTestObjects_MultipleInputParameters_derivedChildObj.xml ProcessMultipleTestObjects_MultipleInputParameters_parentObj.xml ProcessTestObject_NoExpectedOutputFile_testObj.xml ProcessTestObject_NoIgnoreRules_testObj.xml ProcessTestObject_NoRulesFile_testObj.xml ProcessTestObject_default_testObj.xml TestObject.xml etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/rules/TestScenarioHelperTests ProcessTestObject_NoIgnoreRules.xml ProcessTestObject_default.xml etc/andromda-dotnet/AndroMDA.ScenarioUnit AndroMDA.ScenarioUnit.sln etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit AndroMDA.ScenarioUnit.csproj CodeAsserterAttribute.cs CodeDataProviderAttribute.cs IAsserter.cs IDataProvider.cs TestScenarioHelper.cs XMLAsserterAttribute.cs XMLDataProviderAttribute.cs Log: - Initial import Revision Changes Path 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/AndroMDA.ScenarioUnit.Tests.csproj Index: AndroMDA.ScenarioUnit.Tests.csproj =================================================================== <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{B17535E8-28F0-481A-845F-A383F53BF0C1}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>AndroMDA.ScenarioUnit.Tests</RootNamespace> <AssemblyName>AndroMDA.ScenarioUnit.Tests</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <UseVSHostingProcess>true</UseVSHostingProcess> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="nunit.core, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\nunit.core.dll</HintPath> </Reference> <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\nunit.framework.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.configuration" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="TestDerivedObject.cs" /> <Compile Include="TestException.cs" /> <Compile Include="TestObject.cs" /> <Compile Include="TestScenarioHelperTests.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="App.config" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\AndroMDA.ScenarioUnit\AndroMDA.ScenarioUnit.csproj"> <Project>{0133CF39-2F87-45EB-8E8E-81C3A154FC15}</Project> <Name>AndroMDA.ScenarioUnit</Name> </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/App.config Index: App.config =================================================================== <?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" /> <bindingRedirect oldVersion="2.0.6.0" newVersion="2.2.8.0" /> <bindingRedirect oldVersion="2.1.4.0" newVersion="2.2.8.0" /> <bindingRedirect oldVersion="2.2.0.0" newVersion="2.2.8.0" /> </dependentAssembly> </assemblyBinding> </runtime> <appSettings> <add key="TestDataInputDir" value="../../testdata/input"/> <add key="TestDataExpectedOutputDir" value="../../testdata/expected_output"/> <add key="TestDataActualOutputDir" value="../../testdata/actual_output"/> <add key="TestDataRulesDir" value="../../testdata/rules"/> </appSettings> </configuration> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/TestDerivedObject.cs Index: TestDerivedObject.cs =================================================================== using System; using System.Xml; using System.Xml.Serialization; using System.Collections.Generic; using System.Text; namespace AndroMDA.ScenarioUnit.Tests.TestData.Derived { public class TestDerivedObject: AndroMDA.ScenarioUnit.Tests.TestData.Base.TestObject { string middleInitial; public string MiddleInitial { get {return middleInitial;} set {middleInitial = value;} } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/TestException.cs Index: TestException.cs =================================================================== using System; using System.Collections.Generic; using System.Text; namespace AndroMDA.ScenarioUnit.Tests { class TestException: System.Exception { } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/TestObject.cs Index: TestObject.cs =================================================================== using System; using System.Xml.Serialization; using AndroMDA.ScenarioUnit.Tests.TestData.Derived; namespace AndroMDA.ScenarioUnit.Tests.TestData.Base { [XmlInclude(typeof(TestDerivedObject))] [Serializable] public class TestObject { int id; string firstName; string lastName; TestObject child; public int Id { get { return id; } set { id = value; } } public string FirstName { get { return firstName; } set { firstName = value; } } public string LastName { get { return lastName; } set { lastName = value; } } public TestObject Child { get { return child; } set { child = value; } } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/TestScenarioHelperTests.cs Index: TestScenarioHelperTests.cs =================================================================== using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Text; using System.Configuration; using System.IO; using System.Xml; using System.Xml.Serialization; using NUnit.Framework; using AndroMDA.ScenarioUnit; using AndroMDA.ScenarioUnit.Tests.TestData.Base; using AndroMDA.ScenarioUnit.Tests.TestData.Derived; namespace AndroMDA.ScenarioUnit.Tests { [TestFixture] [XMLDataProvider(InputDir = "TestScenarioHelperTests")] [XMLAsserter(ActualOutputDir = "TestScenarioHelperTests", ExpectedOutputDir = "TestScenarioHelperTests", RulesDir = "TestScenarioHelperTests")] public class TestScenarioHelperTests { #region TestInvoke [Test] public void TestInvoke() { TestScenarioHelper.Invoke("ProcessTestObject", "default", this); } [Test] [ExpectedException(typeof(FileNotFoundException))] public void TestInvokeNoInputFile() { TestScenarioHelper.Invoke("ProcessTestObject", "NoInputFile", this); } [Test] [ExpectedException(typeof(FileNotFoundException))] public void TestInvokeNoExpectedOutputFile() { TestScenarioHelper.Invoke("ProcessTestObject", "NoExpectedOutputFile", this); } [Test] public void TestInvokeNoRulesFile() { TestScenarioHelper.Invoke("ProcessTestObject", "NoRulesFile", this); } [Test] public void TestInvokeNoIgnoreRules() { TestScenarioHelper.Invoke("ProcessTestObject", "NoIgnoreRules", this); } private TestObject ProcessTestObject(TestObject testObj) { testObj.Id = 100; return testObj; } #endregion #region TestInvokeMultipleParameters [Test] public void TestInvokeMultipleInputParameters() { TestScenarioHelper.Invoke("ProcessMultipleTestObjects", "MultipleInputParameters", this); } private TestObject ProcessMultipleTestObjects(TestObject parentObj, TestObject baseChildObj, TestDerivedObject derivedChildObj) { parentObj.Id = 100; parentObj.Child = baseChildObj; baseChildObj.Child = derivedChildObj; return parentObj; } #endregion #region TestInvokeNoInputParameter [Test] public void TestInvokeNoInputParameter() { TestScenarioHelper.Invoke("GetTestObject", "NoInputParameter", this); } private TestObject GetTestObject() { TestObject testObj = new TestObject(); testObj.FirstName = "a"; testObj.LastName = "b"; return testObj; } #endregion #region TestInvokePrimitiveInputParameter [Test] public void TestInvokePrimitiveInputParameter() { TestScenarioHelper.Invoke("GetTestObjectWithId", "PrimitiveInputParameter", this); } private TestObject GetTestObjectWithId(int id) { TestObject testObj = new TestObject(); testObj.Id = id; testObj.FirstName = "a"; testObj.LastName = "b"; return testObj; } #endregion #region TestInvokeNoReturnParameter [Test] public void TestInvokeNoReturnParameter() { TestScenarioHelper.Invoke("NoReturn", "NoReturnParameter", this); } private void NoReturn() { return; } #endregion #region TestInvokeMultipleReturnParameters [Test] public void TestInvokeMultipleReturnParameters() { TestScenarioHelper.Invoke("GetMultipleTestObjects", "MultipleReturnParameters", this); } private TestObject GetMultipleTestObjects(TestObject parentObj, out TestDerivedObject derivedChildObj) { derivedChildObj = (TestDerivedObject)parentObj.Child; return parentObj; } #endregion #region TestInvokeCollectionParameters [Test] public void TestInvokeCollectionParameters() { TestScenarioHelper.Invoke("GetTestObjectCollection", "CollectionParameters", this); TestScenarioHelper.Invoke("GetTestObjectList", "ListParameter", this); } private TestObject[] GetTestObjectCollection(int[] ids) { TestObject[] tos = new TestObject[10]; for (int i = 0; i < ids.Length && i < 10; ++i) { TestObject to = new TestObject(); to.FirstName = ids[i].ToString(); to.LastName = string.Format("{0}", (ids[i] + 100)); tos[i] = to; } return tos; } private List<TestObject> GetTestObjectList(int[] ids) { List<TestObject> tos = new List<TestObject>(); for (int i = 0; i < ids.Length && i < 10; ++i) { TestObject to = new TestObject(); to.FirstName = ids[i].ToString(); to.LastName = string.Format("{0}", (ids[i] + 100)); tos.Add(to); } return tos; } #endregion #region TestBusinessException [Test] [ExpectedException(typeof(TestException))] public void TestBusinessException() { TestScenarioHelper.Invoke("ExceptionThrower", "default", this); } private void ExceptionThrower() { throw new TestException(); } #endregion #region TestCodeDataProvider [Test] public void TestCodeDataProvider() { TestScenarioHelper.Invoke("ProcessCodeBasedTestObject", "default", this); } [CodeDataProvider] private void ProcessCodeBasedTestObject(TestObject codeBasedTestObject) { Assert.IsNotNull(codeBasedTestObject); } private object ProcessCodeBasedTestObject_codeBasedTestObject_data(ParameterInfo pinfo, string methodName, string scenarioName) { return new TestObject(); } #endregion #region TestNamedCodeDataProvider [Test] public void TestNamedCodeDataProvider() { TestScenarioHelper.Invoke("ProcessTestObjectFromNamedMethod", "default", this); } [CodeDataProvider(DataMethodName = "TestObjectProvider")] private void ProcessTestObjectFromNamedMethod(TestObject testObject, TestDerivedObject derivedObject) { Assert.IsNotNull(testObject); Assert.IsNotNull(derivedObject); } private object TestObjectProvider(ParameterInfo pinfo, string methodName, string scenarioName) { if (pinfo.ParameterType == typeof(TestObject)) { return new TestObject(); } else if (pinfo.ParameterType == typeof(TestDerivedObject)) { return new TestDerivedObject(); } else { return null; } } #endregion #region TestMixedDataProviders [Test] public void TestMixedDataProvider() { TestScenarioHelper.Invoke("ProcessMixedDataProviders", "default", this); } [XMLDataProvider(InputDir = "TestScenarioHelperTests")] private void ProcessMixedDataProviders(TestObject testObject, [CodeDataProvider] TestDerivedObject derivedObject) { Assert.IsNotNull(testObject); Assert.IsNotNull(derivedObject); } private object ProcessMixedDataProviders_derivedObject_data(ParameterInfo pinfo, string methodName, string scenarioName) { return new TestDerivedObject(); } #endregion #region TestCodeAsserter [Test] public void TestCodeAsserter() { TestScenarioHelper.Invoke("ProcessTestObjectForCodeAssertion", "default", this); } [Test] [ExpectedException(typeof(AssertionException))] public void TestCodeAsserterFailure() { TestScenarioHelper.Invoke("ProcessTestObjectForCodeAssertion", "AssertionFailure", this); } [CodeAsserter] private TestObject ProcessTestObjectForCodeAssertion() { return new TestObject(); } private void ProcessTestObjectForCodeAssertion_Assert(object outputObj, ParameterInfo pInfo, string methodName, string scenarioName) { switch (scenarioName) { case "default": { TestObject testObject = (TestObject)outputObj; Assert.IsNotNull(testObject); break; } case "AssertionFailure": { Assert.IsNull(outputObj); break; } } } #endregion #region TestNamedCodeAsserter [Test] public void TestNamedCodeAsserter() { TestScenarioHelper.Invoke("ProcessTestObjectForNamedCodeAsserter", "scenario1", this); } [CodeAsserter(AsserterMethodName = "TestObjectAsserter")] private TestObject ProcessTestObjectForNamedCodeAsserter(out TestDerivedObject derivedObj) { TestObject testObj = new TestObject(); testObj.FirstName = "manish"; derivedObj = new TestDerivedObject(); derivedObj.FirstName = "derived"; derivedObj.MiddleInitial = "m"; return testObj; } private void TestObjectAsserter(object outputObj, ParameterInfo pinfo, string methodName, string scenarioName) { switch (scenarioName) { case "scenario1": { if (string.IsNullOrEmpty(pinfo.Name)) { Assert.AreEqual("manish", ((TestObject)outputObj).FirstName); } else if (pinfo.Name == "derivedObj") { Assert.AreEqual("m", ((TestDerivedObject)outputObj).MiddleInitial); } else { Assert.Fail("invalid return type"); } break; } default: { Assert.Fail("invalid scenarioname"); break; } } } #endregion #region TestMixedAsserters [Test] public void TestMixedAsserters() { TestScenarioHelper.Invoke("ProcessMixedAsserters", "default", this); } [Test] [ExpectedException(typeof(AssertionException))] public void TestProcessMixedAssertersXMLAssertionFailure() { TestScenarioHelper.Invoke("ProcessMixedAsserters", "XMLAssertionFailure", this); } [Test] [ExpectedException(typeof(AssertionException))] public void TestProcessMixedAssertersCodeAssertionFailure() { TestScenarioHelper.Invoke("ProcessMixedAsserters", "CodeAssertionFailure", this); } private TestObject ProcessMixedAsserters( [CodeAsserter] out TestDerivedObject derivedObject) { TestObject testObj = new TestObject(); testObj.FirstName = "manish"; derivedObject = new TestDerivedObject(); derivedObject.FirstName = "derived"; derivedObject.MiddleInitial = "m"; return testObj; } private void ProcessMixedAsserters_derivedObject_Assert(object outputObj, ParameterInfo pinfo, string methodName, string scenarioName) { switch(scenarioName) { case "default": Assert.AreEqual("m", ((TestDerivedObject)outputObj).MiddleInitial); break; case "CodeAssertionFailure": Assert.Fail("failing derived object assertion."); break; } } #endregion } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/Properties/AssemblyInfo.cs Index: AssemblyInfo.cs =================================================================== using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("AndroMDA.ScenarioUnit.Tests")] [assembly: AssemblyDescription("This assembly contains unit tests for the AndroMDA.ScenarioUnit assembly.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("AndroMDA.org")] [assembly: AssemblyProduct("AndroMDA.ScenarioUnit.Tests")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("993676be-6a6b-4863-8544-809644564c47")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/actual_output/TestScenarioHelperTests/Placeholder.txt <<Binary file>> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/GetMultipleTestObjects_MultipleReturnParameters.xml Index: GetMultipleTestObjects_MultipleReturnParameters.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/GetMultipleTestObjects_MultipleReturnParameters_derivedChildObj.xml Index: GetMultipleTestObjects_MultipleReturnParameters_derivedChildObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestDerivedObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </TestDerivedObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/GetTestObjectCollection_CollectionParameters.xml Index: GetTestObjectCollection_CollectionParameters.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <ArrayOfTestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <TestObject> <Id>0</Id> <FirstName>0</FirstName> <LastName>100</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>1</FirstName> <LastName>101</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>2</FirstName> <LastName>102</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>3</FirstName> <LastName>103</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>4</FirstName> <LastName>104</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>5</FirstName> <LastName>105</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>6</FirstName> <LastName>106</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>7</FirstName> <LastName>107</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>8</FirstName> <LastName>108</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>9</FirstName> <LastName>109</LastName> </TestObject> </ArrayOfTestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/GetTestObjectList_ListParameter.xml Index: GetTestObjectList_ListParameter.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <ArrayOfTestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <TestObject> <Id>0</Id> <FirstName>0</FirstName> <LastName>100</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>1</FirstName> <LastName>101</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>2</FirstName> <LastName>102</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>3</FirstName> <LastName>103</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>4</FirstName> <LastName>104</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>5</FirstName> <LastName>105</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>6</FirstName> <LastName>106</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>7</FirstName> <LastName>107</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>8</FirstName> <LastName>108</LastName> </TestObject> <TestObject> <Id>0</Id> <FirstName>9</FirstName> <LastName>109</LastName> </TestObject> </ArrayOfTestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/GetTestObjectWithId_PrimitiveInputParameter.xml Index: GetTestObjectWithId_PrimitiveInputParameter.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>100</Id> <FirstName>a</FirstName> <LastName>b</LastName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/GetTestObject_NoInputParameter.xml Index: GetTestObject_NoInputParameter.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessMixedAsserters_CodeAssertionFailure.xml Index: ProcessMixedAsserters_CodeAssertionFailure.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>manish</FirstName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessMixedAsserters_XMLAssertionFailure.xml Index: ProcessMixedAsserters_XMLAssertionFailure.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>other</FirstName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessMixedAsserters_default.xml Index: ProcessMixedAsserters_default.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>manish</FirstName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessMultipleTestObjects_MultipleInputParameters.xml Index: ProcessMultipleTestObjects_MultipleInputParameters.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>100</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child> <Id>0</Id> <FirstName>c</FirstName> <LastName>d</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>e</FirstName> <LastName>g</LastName> <MiddleInitial>f</MiddleInitial> </Child> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessTestObject_NoIgnoreRules.xml Index: ProcessTestObject_NoIgnoreRules.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>100</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessTestObject_NoRulesFile.xml Index: ProcessTestObject_NoRulesFile.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>100</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/expected_output/TestScenarioHelperTests/ProcessTestObject_default.xml Index: ProcessTestObject_default.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/GetMultipleTestObjects_MultipleReturnParameters_parentObj.xml Index: GetMultipleTestObjects_MultipleReturnParameters_parentObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/GetTestObjectCollection_CollectionParameters_ids.xml Index: GetTestObjectCollection_CollectionParameters_ids.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <int>0</int> <int>1</int> <int>2</int> <int>3</int> <int>4</int> <int>5</int> <int>6</int> <int>7</int> <int>8</int> <int>9</int> <int>10</int> </ArrayOfInt> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/GetTestObjectList_ListParameter_ids.xml Index: GetTestObjectList_ListParameter_ids.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <int>0</int> <int>1</int> <int>2</int> <int>3</int> <int>4</int> <int>5</int> <int>6</int> <int>7</int> <int>8</int> <int>9</int> <int>10</int> </ArrayOfInt> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/GetTestObjectWithId_PrimitiveInputParameter_id.xml Index: GetTestObjectWithId_PrimitiveInputParameter_id.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <int>100</int> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessMixedDataProviders_default_testObject.xml Index: ProcessMixedDataProviders_default_testObject.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessMultipleTestObjects_MultipleInputParameters_baseChildObj.xml Index: ProcessMultipleTestObjects_MultipleInputParameters_baseChildObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>c</FirstName> <LastName>d</LastName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessMultipleTestObjects_MultipleInputParameters_derivedChildObj.xml Index: ProcessMultipleTestObjects_MultipleInputParameters_derivedChildObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestDerivedObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>e</FirstName> <MiddleInitial>f</MiddleInitial> <LastName>g</LastName> </TestDerivedObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessMultipleTestObjects_MultipleInputParameters_parentObj.xml Index: ProcessMultipleTestObjects_MultipleInputParameters_parentObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessTestObject_NoExpectedOutputFile_testObj.xml Index: ProcessTestObject_NoExpectedOutputFile_testObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessTestObject_NoIgnoreRules_testObj.xml Index: ProcessTestObject_NoIgnoreRules_testObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>100</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessTestObject_NoRulesFile_testObj.xml Index: ProcessTestObject_NoRulesFile_testObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/ProcessTestObject_default_testObj.xml Index: ProcessTestObject_default_testObj.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/input/TestScenarioHelperTests/TestObject.xml Index: TestObject.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Id>0</Id> <FirstName>a</FirstName> <LastName>b</LastName> <Child xsi:type="TestDerivedObject"> <Id>0</Id> <FirstName>c</FirstName> <LastName>e</LastName> <MiddleInitial>d</MiddleInitial> </Child> </TestObject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/rules/TestScenarioHelperTests/ProcessTestObject_NoIgnoreRules.xml Index: ProcessTestObject_NoIgnoreRules.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <rules/> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.Tests/testdata/rules/TestScenarioHelperTests/ProcessTestObject_default.xml Index: ProcessTestObject_default.xml =================================================================== <?xml version="1.0" encoding="utf-8"?> <rules> <ignore> <item>//Id</item> </ignore> </rules> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.sln Index: AndroMDA.ScenarioUnit.sln ===================================================================  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroMDA.ScenarioUnit", "AndroMDA.ScenarioUnit\AndroMDA.ScenarioUnit.csproj", "{0133CF39-2F87-45EB-8E8E-81C3A154FC15}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroMDA.ScenarioUnit.Tests", "AndroMDA.ScenarioUnit.Tests\AndroMDA.ScenarioUnit.Tests.csproj", "{B17535E8-28F0-481A-845F-A383F53BF0C1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0133CF39-2F87-45EB-8E8E-81C3A154FC15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0133CF39-2F87-45EB-8E8E-81C3A154FC15}.Debug|Any CPU.Build.0 = Debug|Any CPU {0133CF39-2F87-45EB-8E8E-81C3A154FC15}.Release|Any CPU.ActiveCfg = Release|Any CPU {0133CF39-2F87-45EB-8E8E-81C3A154FC15}.Release|Any CPU.Build.0 = Release|Any CPU {B17535E8-28F0-481A-845F-A383F53BF0C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B17535E8-28F0-481A-845F-A383F53BF0C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {B17535E8-28F0-481A-845F-A383F53BF0C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {B17535E8-28F0-481A-845F-A383F53BF0C1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.csproj Index: AndroMDA.ScenarioUnit.csproj =================================================================== <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{0133CF39-2F87-45EB-8E8E-81C3A154FC15}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>AndroMDA.ScenarioUnit</RootNamespace> <AssemblyName>AndroMDA.ScenarioUnit</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <PlatformTarget>AnyCPU</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="nunit.core, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\nunit.core.dll</HintPath> </Reference> <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\nunit.framework.dll</HintPath> </Reference> <Reference Include="NXUnit.Framework, Version=1.0.0.19101, Culture=neutral"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\NXUnit.Framework.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.configuration" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="CodeDataProviderAttribute.cs" /> <Compile Include="CodeAsserterAttribute.cs" /> <Compile Include="XMLAsserterAttribute.cs" /> <Compile Include="IAsserter.cs" /> <Compile Include="IDataProvider.cs" /> <Compile Include="TestScenarioHelper.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="XMLDataProviderAttribute.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/CodeAsserterAttribute.cs Index: CodeAsserterAttribute.cs =================================================================== using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace AndroMDA.ScenarioUnit { [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Parameter)] public class CodeAsserterAttribute : Attribute, IAsserter { private string _asserterMethodName; public string AsserterMethodName { get { return _asserterMethodName; } set { _asserterMethodName = value; } } public void AssertOutput(Object outputObj, ParameterInfo pInfo, string methodName, string scenarioName, object testFixture) { if (string.IsNullOrEmpty(AsserterMethodName)) { if (string.IsNullOrEmpty(pInfo.Name)) { AsserterMethodName = string.Format("{0}_Assert", methodName); } else { AsserterMethodName = string.Format("{0}_{1}_Assert", methodName, pInfo.Name); } } MethodInfo mInfo = testFixture.GetType().GetMethod(AsserterMethodName, BindingFlags.NonPublic | BindingFlags.Instance| BindingFlags.IgnoreCase); object[] parameters = new object[] { outputObj, pInfo, methodName, scenarioName }; mInfo.Invoke(testFixture, parameters); } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/CodeDataProviderAttribute.cs Index: CodeDataProviderAttribute.cs =================================================================== using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace AndroMDA.ScenarioUnit { [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Parameter)] public class CodeDataProviderAttribute : Attribute, IDataProvider { private string _dataMethodName; public string DataMethodName { get { return _dataMethodName; } set { _dataMethodName = value; } } public object GetData(ParameterInfo pInfo, string methodName, string scenarioName, object testFixture) { if (string.IsNullOrEmpty(DataMethodName)) { DataMethodName = string.Format("{0}_{1}_Data", methodName, pInfo.Name); } MethodInfo mInfo = testFixture.GetType().GetMethod(DataMethodName, BindingFlags.NonPublic | BindingFlags.Instance| BindingFlags.IgnoreCase); object[] parameters = new object[] { pInfo, methodName, scenarioName }; return mInfo.Invoke(testFixture, parameters); } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/IAsserter.cs Index: IAsserter.cs =================================================================== using System; using System.Reflection; namespace AndroMDA.ScenarioUnit { public interface IAsserter { void AssertOutput(Object outputObj, ParameterInfo pInfo, string methodName, string scenarioName, object testFixture); } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/IDataProvider.cs Index: IDataProvider.cs =================================================================== using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace AndroMDA.ScenarioUnit { public interface IDataProvider { object GetData(ParameterInfo pInfo, string methodName, string scenarioName, object testFixture); } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/TestScenarioHelper.cs Index: TestScenarioHelper.cs =================================================================== using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Reflection; namespace AndroMDA.ScenarioUnit { public class TestScenarioHelper { /// <summary> /// The only public method of this class. /// this is called from test cases and does the following. /// Calls the method specified by the "methodName" attribute; /// passing in all input parameters after reading them from XML files on the disk. /// The following convention is used to determine the file name for reading in a parameter: /// methodName_scenarioName[_parameterName].xml /// The parameterName part is not present for files corresponding to the returned value from a method. /// The value returned from the method call, if any, is saved in XML format to /// a file. /// Next, for all output parameters and return values, assertions are performed by using the expected output XML files. These files are also loaded /// based on the naming convention specified above. /// Before comparing the actual and expected XML files, this method performs cleanup on the /// two XML documents and removes the nodes specified in the "rules" XML file. /// These are nodes like generated identifiers, date time fields etc. that cannot be specified in the expected output because these are determined at run time. /// The location of the four sets of files used in this process is specified by using the /// TestDataInputDir, TestDataExpectedOutputDir, TestDataActualOutputDir, and TestDataRulesDir key-value /// pairs in the configuration file of the test harness. /// </summary> /// <param name="methodName">The test method to execute. This must be a private instance method /// in the TestFixture class.</param> /// <param name="scenarioName">The test scenario.</param> /// <param name="testFixture">The class containing the test method.</param> public static void Invoke(string methodName, string scenarioName, Object testFixture) { MethodInfo mInfo = testFixture.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase); ParameterInfo[] pInfos = mInfo.GetParameters(); ParameterInfo returnParamInfo = mInfo.ReturnParameter; ArrayList allParameters = new ArrayList(); List<ParameterInfo> outParameters = new List<ParameterInfo>(); foreach (ParameterInfo pInfo in pInfos) { Object parameter = null; //Try to load a parameter from an XML //file only if it is an input parameter. //Otherwise, just add the parameterInfo for that parameter //into an array for assertion later. if (pInfo.IsOut) { outParameters.Add(pInfo); } else { IDataProvider dataProvider = GetDataProvider(testFixture, mInfo, pInfo); if (null != dataProvider) { parameter = dataProvider.GetData(pInfo, methodName, scenarioName, testFixture); } } //Add the parameter to the array to be used to call the method //irrespective of whether or not it is an out parameter. //For out parameters, a "null" is added in the array. //This is replaced by an actual object after the method is invoked. allParameters.Add(parameter); } //Call the test method. try { Object[] parameters = allParameters.ToArray(); Object returnObj = mInfo.Invoke(testFixture, parameters); //Save the returned value //and call the corresponding assertion only if the return type is not void. if (returnParamInfo.ParameterType.Name != "Void") { IAsserter outputAsserter = GetOutputAsserter(testFixture, mInfo, returnParamInfo); if (null != outputAsserter) { outputAsserter.AssertOutput(returnObj, returnParamInfo, methodName, scenarioName, testFixture); } } //Save the remaining out parameters and //call the corresponding assertions. foreach (ParameterInfo outPInfo in outParameters) { object outParameter = parameters[outPInfo.Position]; IAsserter outputAsserter = GetOutputAsserter(testFixture, mInfo, outPInfo); if (null != outputAsserter) { outputAsserter.AssertOutput(outParameter, outPInfo, me... [truncated message content] |
From: Manish A. <mag...@us...> - 2007-02-19 06:54:20
|
User: magrawal Date: 07/02/18 22:54:20 Modified: etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit AndroMDA.ScenarioUnit.csproj CodeAsserterAttribute.cs CodeDataProviderAttribute.cs IAsserter.cs IDataProvider.cs TestScenarioHelper.cs XMLAsserterAttribute.cs XMLDataProviderAttribute.cs Log: added documentation. Revision Changes Path 1.3 +2 -1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.csproj Index: AndroMDA.ScenarioUnit.csproj =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- AndroMDA.ScenarioUnit.csproj 14 Jan 2007 04:21:44 -0000 1.2 +++ AndroMDA.ScenarioUnit.csproj 19 Feb 2007 06:54:19 -0000 1.3 @@ -15,10 +15,11 @@ <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> + <DefineConstants>TRACE;DEBUG;w</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <PlatformTarget>AnyCPU</PlatformTarget> + <DocumentationFile>bin\debug\AndroMDA.ScenarioUnit.XML</DocumentationFile> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> 1.2 +81 -6 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/CodeAsserterAttribute.cs Index: CodeAsserterAttribute.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/CodeAsserterAttribute.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- CodeAsserterAttribute.cs 10 Jan 2007 22:56:52 -0000 1.1 +++ CodeAsserterAttribute.cs 19 Feb 2007 06:54:19 -0000 1.2 @@ -4,18 +4,93 @@ using System.Reflection; namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This is a concrete implementation of the <see cref="IAsserter"/> interface + /// that uses helper methods to assert actual output from a test case against expected output. + /// </summary> + /// <remarks> + /// This asserter is similar to the traditional mechanism of using + /// helper methods to separate out assertion logic from the main testing code. + /// <para> + /// This asserter is helpful when used in conjunction with <see cref="XmlAsserter"/> for return values/output parameters + /// that cannot be serialized into XML. + /// </para> + /// <para> + /// This class derives from the <c>System.Attribute</c> class. This + /// allows this class to be configured as the asserter for a test method return value or output parameter. + /// </para> + /// <para> + /// The AttributeUsage attribute for this class: + /// <c>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]</c> + /// ensures that this attribute can be applied at a class, method or at a parameter level. + /// </para> + /// <para> + /// When this attribute is specified at a <c>TestFixture</c> level, + /// all the test method return values and output parameters in that <c>TestFixture</c> are asserted using this asserter + /// unless, if a different asserter is specified at a test method or parameter level. + /// When this asserter is specified as an attribute on the test method, it + /// overrides any asserter configured at the test fixture level. + /// Similarly, when specified at the return value or output parameter level, + /// this data provider is used to assert that parameter, irrespective of the asserter configured at the test method or test fixture levels. + /// </para> + /// </remarks> [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Parameter)] public class CodeAsserterAttribute : Attribute, IAsserter { private string _asserterMethodName; + + /// <summary> + /// This is an optional property to specify the name of the helper method that is called + /// to assert actual output against expected output. + /// </summary> + /// <remarks> + /// If this property is not set, a naiming convention is used to identify the method to be called. + /// The naming convention is: + /// <code escaped="true"> + /// [testMethodName_[parameterName]_assert() + /// </code> + /// <note> + /// In case of return values, there is no "parameterName" part in the naming convention. + /// </note> + /// </remarks> public string AsserterMethodName { get { return _asserterMethodName; } set { _asserterMethodName = value; } } + /// <summary> + /// This is the implementation of the <see cref="IAsserter"/> interface. + /// It uses a helper method to assert actual output against expected test output. + /// </summary> + /// <param name="outputObj">The object containing the actual test output</param> + /// <param name="pInfo">Meta information about the <paramref name="outputObj"/>.</param> + /// <param name="methodName">The name of the test method. This name is used to identify the helper assertion method using a naming convention.</param> + /// <param name="scenarioName">The name of the test scenario.</param> + /// <param name="testFixture">A reference to the object containing the helper method. + /// Usually, this is a reference to the TestFixture itself.</param> + /// <remarks> + /// If the <see cref="AsserterMethodName"/>property is not specified, this data provider uses a + /// naming convention to identify the helper method to + /// be called. + /// <para> + /// The naming convention used is: + /// </para> + ///<code escaped="true"> + /// [testMethodName]_[parameterName]_Assert() + /// </code> + /// <para> + /// The helper method must be a private instance method that has the following signature: + /// </para> + /// <code escaped="true" lang="c#"> + ///private void [testMethodName]_[parameterName]_Assert(object outputObj, ParameterInfo pInfo, string methodName, string scenarioName) + /// </code> + /// <note> + /// To assert return values, the "parameterName" part of the helper method name is ommited. + /// </note> + /// </remarks> public void AssertOutput(Object outputObj, ParameterInfo pInfo, string methodName, string scenarioName, object testFixture) { 1.3 +84 -0 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/CodeDataProviderAttribute.cs Index: CodeDataProviderAttribute.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/CodeDataProviderAttribute.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- CodeDataProviderAttribute.cs 18 Jan 2007 10:49:48 -0000 1.2 +++ CodeDataProviderAttribute.cs 19 Feb 2007 06:54:19 -0000 1.3 @@ -4,18 +4,102 @@ using System.Reflection; namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This is a concrete implementation of the <see cref="IDataProvider"/> interface. + /// This data provider uses helper methods written in the TestFixture class + /// or a separate class to load input data for test cases. + /// </summary> + /// <remarks> + /// This data provider uses reflection ot execute a helper method + /// on an object reference to load the test data for a specific scenario. + /// This method of loading test data is almost the same as the mechanism used in + /// traditional unit testing where test data is separated out into helper methods. + /// This data provider is useful when used in conjunction with the + /// <see cref="XMLDataProvider"/> for input data types that cannot be serialized into XML + /// and therefore cannot be loaded using <see cref="XMlDataProvider"/>. + /// <para> + /// This class derives from the <c>System.Attribute</c> class. This + /// allows this class to be configured as a data provider for a test method parameter. + /// </para> + /// <para> + /// The AttributeUsage attribute for this class: + /// <c>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]</c> + /// ensures that this attribute can be applied at a class, method or at a parameter level. + /// </para> + /// <para> + /// When this attribute is specified at a <c>TestFixture</c> level, + /// all the test method parameters in that <c>TestFixture</c> are loaded using this data provider + /// unless, if a different data provider is specified at a test method or parameter level. + /// When this data provider is specified as an attribute on the test method, it + /// overrides any data provider configured at the test fixture level. + /// Similarly, when specified at the parameter level, this data provider is used to load that parameter, irrespective of the data providers configured at the test method or test fixture levels. + /// </para> + /// </remarks> [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)] public class CodeDataProviderAttribute : Attribute, IDataProvider { private string _dataMethodName; + + /// <summary> + /// This is an optional property that specifies the name of the helper method to be called by + /// this data provider to load input data. + /// </summary> + /// <remarks> + /// If this property is not specified, this data provider uses a + /// naming convention to identify the helper method to + /// be called. + /// <para> + /// The naming convention used is: + /// </para> + ///<code escaped="true"> + /// [testMethodName]_[parameterName]_data() + /// </code> + /// <para> + /// The helper method must be a private instance method that has the following signature: + /// </para> + /// <code escaped="true" lang="c#"> + /// private object [testMethodName]_[parameterName]_data(ParameterInfo pinfo, string methodName, string scenarioName) + /// </code> + /// </remarks> public string DataMethodName { get { return _dataMethodName; } set { _dataMethodName = value; } } + /// <summary> + /// This is the implementation of the <see cref="IDataProvider"/> interface. + /// This implementation uses reflection to invoke a helper method on an object reference to load input data + /// for a test scenario. + /// </summary> + /// <param name="pInfo">Meta information about the input parameter to be loaded.</param> + /// <param name="methodName">The name of the test method whose input parameter needs to be loaded. + /// This name is used in a naming convention to identify the helper method to be + /// called to load the input data.</param> + /// <param name="scenarioName">The name of the test scenario for which test input data needs to be loaded. + /// This name is passed to the helper method that returns input data.</param> + /// <param name="testFixture">This is the object reference that contains the helper method that returns input data. + /// Usually, this is a reference to the TestFixture itself.</param> + /// <returns>Returns the loaded input data as returned from the helper method.</returns> + /// <remarks> + /// If the <see cref="DataMethodName"/>property is not specified, this data provider uses a + /// naming convention to identify the helper method to + /// be called. + /// <para> + /// The naming convention used is: + /// </para> + ///<code escaped="true"> + /// [testMethodName]_[parameterName]_data() + /// </code> + /// <para> + /// The helper method must be a private instance method that has the following signature: + /// </para> + /// <code escaped="true" lang="c#"> + /// private object [testMethodName]_[parameterName]_data(ParameterInfo pinfo, string methodName, string scenarioName) + /// </code> + /// </remarks> public object GetData(ParameterInfo pInfo, string methodName, string scenarioName, object testFixture) { if (string.IsNullOrEmpty(DataMethodName)) 1.2 +48 -0 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/IAsserter.cs Index: IAsserter.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/IAsserter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- IAsserter.cs 10 Jan 2007 22:56:52 -0000 1.1 +++ IAsserter.cs 19 Feb 2007 06:54:19 -0000 1.2 @@ -3,8 +3,56 @@ namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This interface is implemented by all concrete Asserter classes. + /// The implementation of this interface provides the ability to assert that actual output is equal to expected output for a specific test scenario. + /// </summary> + /// <remarks> + /// The implementation of this interface receives the actual output returned + /// by invoking the system under test for a specific scenario + /// and compares this output with expected data stored outside the actual test cases (Similar to the data provider concept.) + /// <para> + /// A concrete asserter that implements this interface needs to + /// derive from the <see cref="System.Attribute"/> class so that it can + /// be configured to be used to assert output data. + /// <para> + /// The asserter should use the following<c>AttributeUsage</c> tag: + /// <para> + /// <c>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]</c> + /// </para> + /// This allows an asserter to be configured at a <c>TestFixture</c>, + /// <c>TestMethod</c>, or a <c>parameter</c> level, giving fine grained control to + /// the developers writing unit tests over how test output is asserted. + /// </para> + /// </para> + /// </remarks> public interface IAsserter { + /// <summary> + /// This method asserts actual output for a specific test scenario + /// with expected output. + /// The <see cref="TestScenarioHelper"/> class calls this method + /// once for each return and output paramter + /// of a test method. + /// </summary> + /// <param name="outputObj">The actual output obtained by invoking the system under test.</param> + /// <param name="pInfo">Meta information about the actual output object. + /// This information can be used by concrete IAsserter implementations to help load the expected output and perform + /// the comparison of actual output with expected output.</param> + /// <param name="methodName">This is the name of the test method being used to invoke the functionality under test. + /// This information can be used by concrete IAsserter implementations to help load the expected output and perform + /// the comparison of actual output with expected output.</param> + /// <param name="scenarioName">The name of the test scenario being executed. + /// This information can be used by concrete IAsserter implementations to help load the expected output and perform + /// the comparison of actual output with expected output.</param> + /// <param name="testFixture">A reference to the class containing the test case or any other helper methods + /// that can help in asserting the output.</param> + /// <remarks> + /// This method receives only the actual output as a parameter + /// and not the expected output because the concrete asserter + /// is required to load/find the expected output on its own using concepts similar to the data provider. + /// Meta information about the output, test method and the test scenario being executed is passed along to this method. + /// </remarks> void AssertOutput(Object outputObj, ParameterInfo pInfo, string methodName, string scenarioName, object testFixture); } } 1.2 +39 -0 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/IDataProvider.cs Index: IDataProvider.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/IDataProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- IDataProvider.cs 10 Jan 2007 22:56:52 -0000 1.1 +++ IDataProvider.cs 19 Feb 2007 06:54:19 -0000 1.2 @@ -5,8 +5,47 @@ namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This is the interface implemented by all data providers. + /// </summary> + /// <remarks> + /// A data provider is used by the <see cref="TestScenarioHelper"/> class to load the input data for + /// a test scenario and pass it to a test method. + /// <para> + /// A data provider that implements this interface needs to + /// derive from the <see cref="System.Attribute"/> class so that it can + /// be configured to be used to read input data. + /// <para> + /// The data provider should use the following<c>AttributeUsage</c> tag: + /// <para> + /// <c>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]</c> + /// </para> + /// This allows a data provider to be configured at a <c>TestFixture</c>, + /// <c>TestMethod</c>, or a <c>parameter</c> level, giving fine grained control to + /// the developers writing unit tests over how test input data is provided for each test case. + /// </para> + /// </para> + /// </remarks> public interface IDataProvider { + /// <summary> + /// <c>TestScenarioHelper</c> calls this method on a concrete implementation of + /// this interface once for each input parameter for a test method. + /// </summary> + /// <param name="pInfo">This is the <c>System.Reflection.ParameterInfo</c> object that contains information about the + /// input parameter to be loaded.</param> + /// <param name="methodName">This is the name of the test method to which the loaded input parameter will be passed. + /// The XML and code-based data providers use this name as a part of of a naming convention to locate the source of input data.</param> + /// <param name="scenarioName">This is the name of the test scenario for which input data needs to be loaded. + /// The XML and code-based concrete data provider implementations use this scenario name as a part of a naming convention to locate the + /// source of input data.</param> + /// <param name="testFixture">This is a reference to an object that contains any helper methods or information that may be needed by a specific data provider. + /// For example, in case of code-based data provider, this object contains the helper method that will return the loaded input parameters.</param> + /// <returns>This method returns the loaded input test method parameter as an object.</returns> + /// <remarks> + /// This method is called by <see cref="TestScenarioHelper"/> on a concrete implementation + /// of this interface for each input parameter of a test method. + /// </remarks> object GetData(ParameterInfo pInfo, string methodName, string scenarioName, object testFixture); } } \ No newline at end of file 1.2 +70 -27 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/TestScenarioHelper.cs Index: TestScenarioHelper.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/TestScenarioHelper.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- TestScenarioHelper.cs 10 Jan 2007 22:56:52 -0000 1.1 +++ TestScenarioHelper.cs 19 Feb 2007 06:54:19 -0000 1.2 @@ -4,33 +4,75 @@ using System.Text; using System.Reflection; + +///<summary> +///This namespace contains the various classes for the AndroMDA.ScenarioUnit library. +///</summary> namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This is the helper class that is used to invoke the functionality provided by the AndroMDA.ScenarioUnit framework. + /// </summary> + /// <remarks> + /// This class has a single public static method + /// <c>Invoke()</c> that is called from test cases to execute a specific test scenario. + /// <para> + /// To be able to use this testing framework, the following + /// configuration entries are required + /// in the app.config file of the test harness: + /// <code escaped="true"> + /// <runtime> + /// <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + ///<dependentAssembly> + ///<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" /> + ///<bindingRedirect oldVersion="2.0.6.0" newVersion="2.2.8.0" /> + ///<bindingRedirect oldVersion="2.1.4.0" newVersion="2.2.8.0" /> + ///<bindingRedirect oldVersion="2.2.0.0" newVersion="2.2.8.0" /> + /// </dependentAssembly> + ///</assemblyBinding> + ///</runtime> + /// </code> + /// </para> + /// <note> + /// The "NewVersion" value in these entries should be the value of the + /// NUnit version being used in the test harness. + /// </note> + /// <para> + /// Look at the MoneyServiceSample in the samples folder of the + /// AndroMDA.ScenarioUnit source to see examples of simple usage of this test framework. + /// </para> + /// <para> + /// To see samples of all possible combinations in which this testing framework can be used, + /// look at the test cases implemented for this framework itself + /// in the AndroMDA.ScenarioUnit.Tests project. + /// </para> + /// </remarks> public class TestScenarioHelper { + + protected TestScenarioHelper() { } + /// <summary> - /// The only public method of this class. - /// this is called from test cases and does the following. - /// Calls the method specified by the "methodName" attribute; - /// passing in all input parameters after reading them from XML files on the disk. - /// The following convention is used to determine the file name for reading in a parameter: - /// methodName_scenarioName[_parameterName].xml - /// The parameterName part is not present for files corresponding to the returned value from a method. - /// The value returned from the method call, if any, is saved in XML format to - /// a file. - /// Next, for all output parameters and return values, assertions are performed by using the expected output XML files. These files are also loaded - /// based on the naming convention specified above. - /// Before comparing the actual and expected XML files, this method performs cleanup on the - /// two XML documents and removes the nodes specified in the "rules" XML file. - /// These are nodes like generated identifiers, date time fields etc. that cannot be specified in the expected output because these are determined at run time. - /// The location of the four sets of files used in this process is specified by using the - /// TestDataInputDir, TestDataExpectedOutputDir, TestDataActualOutputDir, and TestDataRulesDir key-value - /// pairs in the configuration file of the test harness. + /// This is the method used to invoke a test method for a specific scenario. /// </summary> /// <param name="methodName">The test method to execute. This must be a private instance method /// in the TestFixture class.</param> /// <param name="scenarioName">The test scenario.</param> /// <param name="testFixture">The class containing the test method.</param> + /// <remarks> + /// this method is called from an NUnit test case and does the following: + /// <list type="bullet"> + /// <item> + /// Calls the method specified by the <c>methodName</c> parameter; + /// passing in all input parameters by using the concrete implementation of <see cref="IDataProvider"/> configured for each parameter. + /// </item> + /// <item> + /// Captures the actual output returned from the test method and + /// compares it with the expected output using the concrete implementation of <see cref="IAsserter"/> configured for each return value + /// and out/ref parameter. + /// </item> + /// </list> + /// </remarks> public static void Invoke(string methodName, string scenarioName, Object testFixture) { MethodInfo mInfo = testFixture.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase); @@ -41,8 +83,8 @@ foreach (ParameterInfo pInfo in pInfos) { Object parameter = null; - //Try to load a parameter from an XML - //file only if it is an input parameter. + //Try to load a parameter + //only if it is an input parameter. //Otherwise, just add the parameterInfo for that parameter //into an array for assertion later. if (pInfo.IsOut) @@ -95,6 +137,7 @@ throw e.InnerException; } } + #region private helper methods /// <summary> /// Helper method to get the asserter to be used for a test case. 1.4 +196 -0 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/XMLAsserterAttribute.cs Index: XMLAsserterAttribute.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/XMLAsserterAttribute.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- XMLAsserterAttribute.cs 18 Jan 2007 10:49:48 -0000 1.3 +++ XMLAsserterAttribute.cs 19 Feb 2007 06:54:19 -0000 1.4 @@ -12,6 +12,72 @@ namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This is a concrete implementation of the <see cref="IAsserter"/> interface that uses XML files to store and compare expected output + /// with actual output objects serialized into XML. + /// </summary> + /// <remarks> + /// This asserter uses XML asserts to compare actual and expected output from a test scenario. + /// Internally, it uses an open source XML-based unit testing framework called + /// NXUnit <see ref="http://www.sf.net/NXUnit"/> to perform the XML comparisons. + /// <para> + /// Similar to the <see cref="XMLDataProvider"/>, this asserter also uses the + /// XML format produced by serializing an object using the System.Xml.Serialization.XmlSerializer class. + /// This means that this asserter can be used to assert only those return/output types + /// that can be serialized into XML. + /// </para> + /// <para> + /// The <see cref="TestScenarioHelper"/> class constructs a concrete instance of this asserter + /// for each return value/output parameter that is configured to use this asserter for a test method. + /// </para> + /// <para> + /// The following 3 entries are required in the + /// test harness app.config file to use this asserter: + /// </para> + /// <para> + /// <code escaped="true"> + /// <appSettings> + /// <add key="TestDataExpectedOutputDir" value="../../testdata/expected_output"/> + ///<add key="TestDataActualOutputDir" value="../../testdata/actual_output"/> + ///<add key="TestDataRulesDir" value="../../testdata/rules"/> + ///</appSettings> + /// + /// </code> + /// </para> + /// <para> + /// These 3 entries specify the folders that store the following: + /// <list type="bullet"> + /// <item>expected output as serialized XML</item> + /// <item>actual output generated by executing a test case</item> + /// <item>XML comparison rules for ignoring the values that cannot be compared between actual and expected output, e.g. database generated IDs etc. (more details below)</item> + /// </list> + /// </para> + /// <para> + /// This asserter provides the ability to ignore parts of the output while comparing actual and expected values. + /// This is required for values that cannot be predicted and cannot be a part of the expected output, such as + /// a date time field that stores the current date/time value or an ID field that is generated in the database. + /// Rules can be created to ignore such items while asserting actual and expected outputs. These rules + /// take the form of XPath queries that specify exact nodes in the serialized XML object to be compared. + /// </para> + /// <para> + /// This class derives from the <c>System.Attribute</c> class. This + /// allows this class to be configured as the asserter for a test method return value or output parameter. + /// </para> + /// <para> + /// The AttributeUsage attribute for this class: + /// <c>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]</c> + /// ensures that this attribute can be applied at a class, method or at a parameter level. + /// </para> + /// <para> + /// When this attribute is specified at a <c>TestFixture</c> level, + /// all the test method return values and output parameters in that <c>TestFixture</c> are asserted using this asserter + /// unless, if a different asserter is specified at a test method or parameter level. + /// When this asserter is specified as an attribute on the test method, it + /// overrides any asserter configured at the test fixture level. + /// Similarly, when specified at the return value or output parameter level, + /// this data provider is used to assert that parameter, irrespective of the asserter configured at the test method or test fixture levels. + /// </para> + /// </remarks> [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)] public class XMLAsserterAttribute : Attribute, IAsserter @@ -21,6 +87,27 @@ private string _expectedOutputDir; private string _rulesDir; + /// <summary> + /// This property is used in conjunction with the + /// configuration entry + /// <code escaped="true"> + /// <add key="TestDataActualOutputDir" value="[somePath]"/> + /// </code> + /// <para> + /// This configuration entry specifies the directory in which all + /// actual output is dumped as serialized XML. + /// This property is used to specify a sub-directory below the TestDataActualOutputDir + /// folder. + /// </para> + /// </summary> + /// <remarks> + /// This property helps organize test output data in + /// sub-folders below the TestDataActualOutputDir folder. + /// <para> + /// This property is optional and if it is not + /// set, the methods in this class will output all actual output in the TestDataActualOutputDir folder. + /// </para> + /// </remarks> public string ActualOutputDir { get @@ -35,6 +122,27 @@ set { _actualOutputDir = value; } } + /// <summary> + /// This property is used in conjunction with the + /// configuration entry + /// <code escaped="true"> + /// <add key="TestDataExpectedOutputDir" value="[somePath]"/> + /// </code> + /// <para> + /// This configuration entry specifies the directory in which + /// expected test output is stored as serialized XML. + /// This property is used to specify a sub-directory below the TestDataExpectedOutputDir + /// folder. + /// </para> + /// </summary> + /// <remarks> + /// This property helps organize expected test output data in + /// sub-folders below the TestDataExpectedOutputDir folder. + /// <para> + /// This property is optional and if it is not + /// set, the methods in this class will look for expected test output in the TestDataExpectedOutputDir folder. + /// </para> + /// </remarks> public string ExpectedOutputDir { get @@ -49,6 +157,29 @@ set { _expectedOutputDir = value; } } + /// <summary> + /// This property is used in conjunction with the + /// configuration entry + /// <code escaped="true"> + /// <add key="TestDataRulesDir" value="[somePath]"/> + /// </code> + /// <para> + /// This configuration entry specifies the directory in which + /// XML comparison rules are stored as XPath queries. These XPath queries specify the parts of actual and expected output + /// XML files that do not need to be compared while asserting actual output against expected output. + /// This property is used to specify a sub-directory below the TestDataRulesDir + /// folder. + /// </para> + /// </summary> + /// <remarks> + /// This property helps organize test assertion rules in + /// sub-folders below the TestDataRulesDir folder. + /// <para> + /// This property is optional and if it is not + /// set, the methods in this class will look for assertion ignore rules + /// in the TestDataRulesDir folder. + /// </para> + /// </remarks> public string RulesDir { get @@ -65,6 +196,71 @@ #endregion #region interface implementation + /// <summary> + /// This method implements the <see cref="IAsserter"/> interface. + /// In this implementation, actual and expected output is serialized as XML + /// and then compared using an open source XML-based framework named NXUnit + /// <see ref="http://www.sf.net/NXUnit"/>. + /// </summary> + /// <param name="outputObj">The actual output returned from the system under test.</param> + /// <param name="pInfo">Meta information about the <paramref name="outputObj"/> object.</param> + /// <param name="methodName">The name of the test method. + /// This name is used as a part of file naming convention used to name actual output, expected output and rules XML files.</param> + /// <param name="scenarioName"> + /// The name of the test scenario. + /// This name is used as a part of file naming convention used to name actual output, expected output and rules XML files. + /// </param> + /// <param name="testFixture">This parameter is not used by this asserter.</param> + /// <remarks> + /// This method is called by the <see cref="TestScenarioHelper"/> class once for + /// every return value/output parameter of a test method for which + /// this asserter is configured. + /// <para> + /// This method serializes the actual test output returned from the + /// system under test using the System.Xml.Serialization.XmlSerializer class. + /// </para> + /// <para> + /// This method also saves the actual output to a physical file, so that it + /// can be reviewed manually after the test case is run. This file is created in the folder + /// specified by the <see cref="ActualOutputDir"/> property. + /// </para> + /// <para> + /// The name of the physical file is created using the same naming convention as that used + /// by the <see cref="XMLDataProvider"/> class: methodName_scenarioName_parameterName.xml. + /// <note> + /// In case of return parameters, there is no "parameterName", so, the file name is just methodName_scenarioName.xml. + /// </note> + /// </para> + /// <para> + /// This method reads expected output from XML files from the location + /// specified by the <see cref="ExpectedOutputDir"/> property. + /// </para> + /// <para> + /// The file naming convention used to identify the file to be read is the same here as well: + /// methodName_scenarioName_parameterName.xml. + /// </para> + /// <para> + /// Not all values in actual and expected output can be compared + /// in some situations. + /// </para> + /// <para> + /// For example, the output may contain a generated ID from the database + /// or a dateTime field that is filled with the current + /// date time value by the system under test. + /// </para> + /// <para> + /// Such parts that cannot be compared need to be ignored while + /// asserting the actual output against expected output. This can be done by creating a rules + /// file for the specific return value/output parameter for each test scenario. + /// </para> + /// <para> + /// This rules file takes the form of an XML file + /// with XPath queries identifying the nodes in the actual and expected + /// output XML files that need to be ignored. This rules file also + /// follows the same naming convention of methodName_scenarioName_parameterName.xml + /// and is placed in the directory specified by the <see cref="RulesDir"/> property. + /// </para> + /// </remarks> public void AssertOutput(Object outputObj, ParameterInfo pInfo, string methodName, string scenarioName, object testFixture) { SaveOutput(outputObj, pInfo, methodName, scenarioName); 1.3 +134 -0 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/XMLDataProviderAttribute.cs Index: XMLDataProviderAttribute.cs =================================================================== RCS file: /cvsroot/andromdaplugins/plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/AndroMDA.ScenarioUnit/XMLDataProviderAttribute.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- XMLDataProviderAttribute.cs 18 Jan 2007 10:49:48 -0000 1.2 +++ XMLDataProviderAttribute.cs 19 Feb 2007 06:54:19 -0000 1.3 @@ -10,6 +10,42 @@ namespace AndroMDA.ScenarioUnit { + /// <summary> + /// This is a concrete implementation of the <see cref="IDataProvider"/> interface. + /// This data provider loads input data stored as serialized XML objects in files. + /// </summary> + /// <remarks> + /// To use this data provider, the following configuration entry is required in the configuration file of the test harness: + /// <para> + /// <code escaped="true"> + /// <add key="TestDataInputDir" value="[somePath]" /> + /// </code> + /// </para> + /// <para> + /// This entry specifies the path where all the input + /// XML files are located. + /// <note> + /// A path relative to the test harness assembly binary (usually located in testHarness/bin/debug) can be specified for this configuration entry. + /// </note> + /// </para> + /// <para> + /// This class derives from the <c>System.Attribute</c> class. This + /// allows this class to be configured as a data provider for a test method parameter. + /// </para> + /// <para> + /// The AttributeUsage attribute for this class: + /// <c>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]</c> + /// ensures that this attribute can be applied at a class, method or at a parameter level. + /// </para> + /// <para> + /// When this attribute is specified at a <c>TestFixture</c> level, + /// all the test method parameters in that <c>TestFixture</c> are loaded using this data provider + /// unless, if a different data provider is specified at a test method or parameter level. + /// When this data provider is specified as an attribute on the test method, it + /// overrides any data provider configured at the test fixture level. + /// Similarly, when specified at the parameter level, this data provider is used to load that parameter, irrespective of the data providers configured at the test method or test fixture levels. + /// </para> + /// </remarks> [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)] public class XMLDataProviderAttribute : Attribute, IDataProvider @@ -17,6 +53,24 @@ #region member variables and properties. private string _inputDir; + /// <summary> + /// This property is used in conjunction with the + /// configuration entry + /// <code escaped="true"> + /// <add key="TestDataInputDir" value="[some path]"> + /// </code> + /// This configuration entry specifies the directory that contains all input data XML files. + /// This property is used to specify a sub-directory below the TestDataInputDir + /// folder that will be used to load the input data. + /// </summary> + /// <remarks> + /// This property helps organize test input data in + /// sub-folders below the TestDataInputDir folder. + /// <para> + /// This property is optional and if it is not + /// set, the methods in this class will look for test input XML files in the TestDataInputDir folder. + /// </para> + /// </remarks> public string InputDir { get @@ -33,6 +87,86 @@ #endregion #region public methods + /// <summary> + /// This is the concrete implementation of the + /// <see cref="IDataProvider"/> interface. + /// This method loads an input parameter for a test method for a specific scenario from an XML file. + /// </summary> + /// <param name="pInfo">This is the <c>System.Reflection.ParameterInfo</c> object that contains information about the + /// input parameter to be loaded.</param> + /// <param name="methodName">This is the name of the test method to which the loaded input parameter will be passed. + /// This data provider uses this methodName value as a part of a naming convention to locate the XML file that contains input data. + /// The input XML file is named using the convention [methodName_scenarioName_parameterName.xml] </param> + /// <param name="scenarioName">This is the name of the test scenario for which input data needs to be loaded. + /// This data provider uses the scenarioName value as a part of a naming convention to locate the XML file that contains input data. + /// The input XML file is named using the convention [methodName_scenarioName_parameterName.xml] </param> + /// <param name="testFixture">This parameter is not currently used by this data provider. </param> + /// <returns>This method returns the loaded input test method parameter as an object.</returns> + /// <remarks> + /// The input data is stored as serialized XML for the object to be loaded. + /// The XML schema used is the one generated by serializing the object using <c>System.Xml.Serialization.XmlSerializer</c>. + /// This method uses a convention to locate the XML file to be read to load and return the object. + /// <para> + /// The XML file name is constructed using the three parameters <paramref name="pInfo"/>, <paramref name="methodName"/>, and <paramref name="scenarioName"/>. + /// The file name is assumed to be : + /// <para> + /// methodName_scenarioName_parameterName.xml + /// </para> + /// For example, to load the input parameters for the test method <c>private Money Add(Money m1, Money m2)</c> + /// for the following invokation: <c>TestScenarioHelper.Invoke("Add", "SimpleAdd", this)</c> + /// this method will look for the files Add_SimpleAdd_m1.xml and + /// Add_SimpleAdd_m2.xml in the <see cref="XMLDataProvider.InputDir"/> directory. + /// </para> + /// <note> + /// you can use code similar to the following to generate the first XML file for an object and then copy it + /// over and over for multiple scenarios replacing specific values according to the input scenario. + /// <para> + /// <code lang="c#"> + /// Money m1 = new Money(1, "USD"); + /// XMLSerializer xs = new XMLSerializer(typeof(Money)); + /// using (StreamWriter sw = new StreamWriter(File.OpenWrite("Add_SimpleAdd_m1.xml"))) + /// { + /// xs.Serialize(sw, m1); + /// } + /// </code> + /// </para> + /// </note> + /// <note> + /// While trying to read polymorphic objects, + /// i.e. trying to read a derived object while the input parameter is of the base type, + /// make sure that the base type definition has an <c>[XMLInclude()]</c> attribute refering to the derived type. + /// </note> + /// </remarks> + /// <example> + /// This example shows the serialized form of the following Money class: + /// <code lang="c#"> + /// + /// namespace MoneyServiceSample + ///{ + /// public class Money + /// { + /// public int amount; + /// public string currency; + /// public Money() { } + /// + /// public Money(int amt, string crncy) + /// { + /// amount = amt; + /// currency = crncy; + /// } + /// } + ///} + /// + /// </code> + /// The following is the Add_SimpleAdd_m1.xml file: + /// <code escaped="true"> + /// <?xml version="1.0" encoding="utf-8"?> + ///<Money xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + /// <amount>12</amount> + /// <currency>CHF</currency> + ///</Money> + /// </code> + /// </example> public object GetData(ParameterInfo pInfo, string methodName, string scenarioName, object testFixture) { string inputFileName = GetFileName(pInfo, methodName, scenarioName); |