Browse Source

Adds unit tests for double extension methods + Fixes a build problem on Mono

Former-commit-id: 8207e6dc22d5d71288274a2ca58e3346c59224b8
pull/17/head
Thomas Broust 12 years ago
committed by James South
parent
commit
bb4301ab3c
  1. 55
      src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs
  2. 4
      src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj
  3. 6
      src/ImageProcessor/ImageProcessor.csproj

55
src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs

@ -0,0 +1,55 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DoubleExtensionsUnitTests.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Runs unit tests on the <see cref="DoubleExtensions" /> extension methods
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests
{
using System;
using System.Collections.Generic;
using Common.Extensions;
using NUnit.Framework;
/// <summary>
/// Test harness for the DoubleExtensions extension methods
/// </summary>
[TestFixture]
public class DoubleExtensionsUnitTests
{
/// <summary>
/// Stores the values to test for the ToByte() extension method
/// </summary>
private Dictionary<double, byte> doubleToByteTests;
/// <summary>
/// Sets up the values for the tests
/// </summary>
[TestFixtureSetUp]
public void Init()
{
this.doubleToByteTests = new Dictionary<double, byte>();
this.doubleToByteTests.Add(-10, 0x0);
this.doubleToByteTests.Add(1.5, 0x1);
this.doubleToByteTests.Add(25.7, 0x19);
this.doubleToByteTests.Add(1289047, 0xFF);
}
/// <summary>
/// Tests the double to byte conversion
/// </summary>
[Test]
public void TestDoubleToByte()
{
foreach (var item in this.doubleToByteTests)
{
var result = item.Key.ToByte();
Assert.AreEqual(item.Value, result);
}
}
}
}

4
src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj

@ -46,6 +46,7 @@
<Compile Include="ImageFactoryUnitTests.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
<Compile Include="Extensions\DoubleExtensionsUnitTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@ -127,4 +128,7 @@
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<ItemGroup />
<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>
</Project>

6
src/ImageProcessor/ImageProcessor.csproj

@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
@ -25,7 +23,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\ImageProcessor.XML</DocumentationFile>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -46,6 +43,8 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@ -57,6 +56,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Security" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\Extensions\AssemblyExtensions.cs" />

Loading…
Cancel
Save