Skip to content

Commit

Permalink
Improve this code (#20)
Browse files Browse the repository at this point in the history
* Updated

* Updated

* Update

* more update
  • Loading branch information
OsirisTerje authored Oct 5, 2023
1 parent 7504357 commit 637aa01
Show file tree
Hide file tree
Showing 30 changed files with 1,222 additions and 2,088 deletions.
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

33 changes: 3 additions & 30 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
## Build Scripts
## Build

Each of the sample solutions can be built individually within Visual Studio. To build and test all solutions, a **Cake** (http://cakebuild.net) script is provided.
The primary script that controls this is build.cake. We modify build.cake when we need to add new
targets or change the way the build is done. Normally build.cake is not invoked directly but through
build.ps1 (on Windows) or build.sh (on Linux). These two scripts are provided by the Cake project
and ensure that Cake is properly installed before trying to run the cake script. This helps the
build to work on CI servers using newly created agents to run the build and we generally run it
the same way on our own machines.
The solution can be built and run using Visual Studio, Visual Studio Code, or the command line using `dotnet test`.

The build shell script and build.cmd script are provided as an easy way to run the above commands.
In addition to passing their arguments through to build.cake, they can supply added arguments
through the CAKE_ARGS environment variable. The rest of this document will assume use of these commands.

There is one case in which use of the CAKE_ARGS environment variable will be essential, if not necessary.
If you are running builds on a 32-bit Windows system, you must always supply the -Experimental argument
to the build. Use set CAKE_ARGS=-Experimental to ensure this is always done and avoid having to type
it out each time.

Key arguments to build.cmd / build:
* -Target, -t <task> The task to run - see below.
* -Configuration, -c [Release|Debug] The configuration to use (default is Debug).
* -Experimental, -e Use the experimental build of Roslyn.

The build.cake script contains a number of interdependent tasks. The most
important top-level tasks to use are listed here:

```
* Build Builds everything. This is the default if no target is given.
* Rebuild Cleans the output directory and builds everything.
* Test Runs all tests. Dependent on Build.
```
There is a CI build on github actions that runs on every push and pullrequest to any branch.
69 changes: 8 additions & 61 deletions DataDrivenTests/DataDrivenTests.csproj
Original file line number Diff line number Diff line change
@@ -1,66 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FBBC6F15-E718-4080-832C-9D1F4B7A352A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DataDrivenTests</RootNamespace>
<AssemblyName>DataDriven.Tests</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright ©NUnit 2018</Copyright>
</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="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataDrivenTestFixture.cs" />
<Compile Include="GenericTestFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="4.0.0-dev-07984" />
<PackageReference Include="NUnit.Analyzers" Version="3.8.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
</Project>
36 changes: 0 additions & 36 deletions DataDrivenTests/Properties/AssemblyInfo.cs

This file was deleted.

5 changes: 0 additions & 5 deletions DataDrivenTests/packages.config

This file was deleted.

59 changes: 0 additions & 59 deletions ExpectedExceptionExample/AssemblyInfo.cs

This file was deleted.

7 changes: 4 additions & 3 deletions ExpectedExceptionExample/ExpectedExceptionAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;

namespace NUnit.Framework
namespace ExpectedExceptionExample
{
/// <summary>
/// A simple ExpectedExceptionAttribute
Expand Down Expand Up @@ -52,10 +53,10 @@ public override TestResult Execute(TestExecutionContext context)
context.CurrentResult.SetResult(ResultState.Success);
else if (caughtType != null)
context.CurrentResult.SetResult(ResultState.Failure,
string.Format("Expected {0} but got {1}", _expectedType.Name, caughtType.Name));
$"Expected {_expectedType.Name} but got {caughtType.Name}");
else
context.CurrentResult.SetResult(ResultState.Failure,
string.Format("Expected {0} but no exception was thrown", _expectedType.Name));
$"Expected {_expectedType.Name} but no exception was thrown");

return context.CurrentResult;
}
Expand Down
125 changes: 8 additions & 117 deletions ExpectedExceptionExample/ExpectedExceptionExample.csproj
Original file line number Diff line number Diff line change
@@ -1,122 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>7.10.3077</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A6E1D464-9AAF-4CA9-A818-819739132281}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<AssemblyKeyContainerName />
<AssemblyName>ExpectedExceptionExample.Tests</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>ExpectedExceptionExample</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<FileUpgradeFlags>
</FileUpgradeFlags>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright ©NUnit 2018</Copyright>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile />
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile />
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile />
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile />
<FileAlignment>4096</FileAlignment>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.9.0\lib\net20\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="NUnit.System.Linq, Version=0.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.9.0\lib\net20\NUnit.System.Linq.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ExpectedExceptionAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ExpectedExceptionTests.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="4.0.0-dev-07984" />
<PackageReference Include="NUnit.Analyzers" Version="3.8.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent />
<PostBuildEvent />
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions ExpectedExceptionExample/ExpectedExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ public void HandlesArgumentExceptionAsType()
{
throw new ArgumentException();
}

[Test]
public void HandlesArgumentExceptionWithNewSyntax()
{
Assert.Throws<ArgumentException>(() => throw new ArgumentException());
}
}
}
4 changes: 0 additions & 4 deletions ExpectedExceptionExample/packages.config

This file was deleted.

Loading

0 comments on commit 637aa01

Please sign in to comment.