From: Manish A. <mag...@us...> - 2007-02-19 06:37:12
|
User: magrawal Date: 07/02/18 22:37:13 Added: etc/andromda-dotnet/AndroMDA.ScenarioUnit/samples/MoneyServiceSample/MoneyServiceSample Money.cs MoneyService.cs MoneyServiceSample.csproj etc/andromda-dotnet/AndroMDA.ScenarioUnit/samples/MoneyServiceSample/MoneyServiceTests App.config MoneyServiceTest.cs MoneyServiceTests.csproj Log: added sample for using the testing framework. Revision Changes Path 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/samples/MoneyServiceSample/MoneyServiceSample/Money.cs Index: Money.cs =================================================================== using System; namespace MoneyServiceSample { public class Money { public int amount; public string currency; public Money() { } public Money(int amt, string crncy) { amount = amt; currency = crncy; } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/samples/MoneyServiceSample/MoneyServiceSample/MoneyService.cs Index: MoneyService.cs =================================================================== using System; namespace MoneyServiceSample { public class MoneyService { public static Money Add(Money m1, Money m2) { Money result = new Money(); result.currency = m1.currency; if (m1.currency == m2.currency) { result.amount = m1.amount + m2.amount; } else { //add a conversion factor to convert from m2.currency to m1.currency. //A constant is used here. In real life, this will be some complicated logic. result.amount = m1.amount + m2.amount + 20; } return result; } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/samples/MoneyServiceSample/MoneyServiceSample/MoneyServiceSample.csproj Index: MoneyServiceSample.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>{9454A3E4-098B-4559-86E4-A6257887726E}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>MoneyServiceSample</RootNamespace> <AssemblyName>MoneyServiceSample</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> </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="System" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Money.cs" /> <Compile Include="MoneyService.cs" /> <Compile Include="Properties\AssemblyInfo.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/samples/MoneyServiceSample/MoneyServiceTests/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/samples/MoneyServiceSample/MoneyServiceTests/MoneyServiceTest.cs Index: MoneyServiceTest.cs =================================================================== using System; using System.IO; using System.Xml; using System.Xml.Serialization; using AndroMDA.ScenarioUnit; using NUnit.Framework; using MoneyServiceSample; namespace MoneyServiceTests { [TestFixture] [XMLDataProvider(InputDir = "MoneyServiceTests")] [XMLAsserter(ActualOutputDir = "MoneyServiceTests", ExpectedOutputDir = "MoneyServiceTests")] public class MoneyServiceTest { [Test] public void TestSimpleAdd() { TestScenarioHelper.Invoke("Add", "SimpleAdd", this); } [Test] public void TestMultipleCurrencyAdd() { //Money m1 = new Money(1, "CHF"); //XmlSerializer xs = new XmlSerializer(typeof(Money)); //using (StreamWriter sw = new StreamWriter(File.OpenWrite("money.xml"))) //{ // xs.Serialize(sw, m1); //} TestScenarioHelper.Invoke("Add", "MultipleCurrencyAdd", this); } private Money Add(Money m1, Money m2) { return MoneyService.Add(m1, m2); } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.ScenarioUnit/samples/MoneyServiceSample/MoneyServiceTests/MoneyServiceTests.csproj Index: MoneyServiceTests.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>{9D05B523-5603-4300-BA05-EB01FA5EC85C}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>MoneyServiceTests</RootNamespace> <AssemblyName>MoneyServiceTests</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> </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="AndroMDA.ScenarioUnit, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\AndroMDA.ScenarioUnit.dll</HintPath> </Reference> <Reference Include="nunit.core, Version=2.2.9.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\nunit.core.dll</HintPath> </Reference> <Reference Include="nunit.framework, Version=2.2.9.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.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="MoneyServiceTest.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\MoneyServiceSample\MoneyServiceSample.csproj"> <Project>{9454A3E4-098B-4559-86E4-A6257887726E}</Project> <Name>MoneyServiceSample</Name> </ProjectReference> </ItemGroup> <ItemGroup> <None Include="App.config" /> </ItemGroup> <ItemGroup> <Folder Include="testdata\actual_output\MoneyServiceTests\" /> <Folder Include="testdata\expected_output\MoneyServiceTests\" /> <Folder Include="testdata\input\MoneyServiceTests\" /> <Folder Include="testdata\rules\" /> </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> |