From b1541d6bcdc75ed8ae5d260dc73d33639402ce13 Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 25 Apr 2015 12:17:58 +0100 Subject: [PATCH] Adding more structs and tests Former-commit-id: c555dd4321d4c11490aa73f8f0d4509679991282 Former-commit-id: 0072a5aac08319d389358dd2f4d274038240fe0e Former-commit-id: f443d31725e0c4bc2d633ec6df65cb6b513b4b8b --- .nuget/packages.config | 4 + ImageProcessor.sln | 11 + .../Settings.StyleCop => Settings.StyleCop | 0 src/ImageProcessor/ImageProcessor.csproj | 4 +- .../ImageProcessor.csproj.DotSettings | 3 +- src/ImageProcessor/{ => Numerics}/Point.cs | 68 ++++- src/ImageProcessor/Numerics/Rectangle.cs | 262 ++++++++++++++++++ src/ImageProcessor/Numerics/Size.cs | 175 ++++++++++++ src/ImageProcessor/Properties/AssemblyInfo.cs | 2 +- .../ImageProcessor.Tests.csproj | 110 ++++++++ .../ImageProcessor.Tests.csproj.DotSettings | 2 + .../Numerics/PointTests.cs | 55 ++++ .../Numerics/RectangleTests.cs | 71 +++++ .../Numerics/SizeTests.cs | 55 ++++ .../Properties/AssemblyInfo.cs | 36 +++ tests/ImageProcessor.Tests/packages.config | 8 + 16 files changed, 854 insertions(+), 12 deletions(-) create mode 100644 .nuget/packages.config rename src/ImageProcessor/Settings.StyleCop => Settings.StyleCop (100%) rename src/ImageProcessor/{ => Numerics}/Point.cs (58%) create mode 100644 src/ImageProcessor/Numerics/Rectangle.cs create mode 100644 src/ImageProcessor/Numerics/Size.cs create mode 100644 tests/ImageProcessor.Tests/ImageProcessor.Tests.csproj create mode 100644 tests/ImageProcessor.Tests/ImageProcessor.Tests.csproj.DotSettings create mode 100644 tests/ImageProcessor.Tests/Numerics/PointTests.cs create mode 100644 tests/ImageProcessor.Tests/Numerics/RectangleTests.cs create mode 100644 tests/ImageProcessor.Tests/Numerics/SizeTests.cs create mode 100644 tests/ImageProcessor.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/ImageProcessor.Tests/packages.config diff --git a/.nuget/packages.config b/.nuget/packages.config new file mode 100644 index 000000000..091917678 --- /dev/null +++ b/.nuget/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ImageProcessor.sln b/ImageProcessor.sln index 340f1858e..4be37800d 100644 --- a/ImageProcessor.sln +++ b/ImageProcessor.sln @@ -5,6 +5,13 @@ VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "src\ImageProcessor\ImageProcessor.csproj", "{8047C4AC-7097-4DE4-B00D-6D55EBCF1D36}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Tests", "tests\ImageProcessor.Tests\ImageProcessor.Tests.csproj", "{1741DC66-5404-4B15-AE58-B7721F1568A4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{3D5BCCE2-A7EB-4453-9A86-A9C55CCFDCDF}" + ProjectSection(SolutionItems) = preProject + .nuget\packages.config = .nuget\packages.config + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +22,10 @@ Global {8047C4AC-7097-4DE4-B00D-6D55EBCF1D36}.Debug|Any CPU.Build.0 = Debug|Any CPU {8047C4AC-7097-4DE4-B00D-6D55EBCF1D36}.Release|Any CPU.ActiveCfg = Release|Any CPU {8047C4AC-7097-4DE4-B00D-6D55EBCF1D36}.Release|Any CPU.Build.0 = Release|Any CPU + {1741DC66-5404-4B15-AE58-B7721F1568A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1741DC66-5404-4B15-AE58-B7721F1568A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1741DC66-5404-4B15-AE58-B7721F1568A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1741DC66-5404-4B15-AE58-B7721F1568A4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ImageProcessor/Settings.StyleCop b/Settings.StyleCop similarity index 100% rename from src/ImageProcessor/Settings.StyleCop rename to Settings.StyleCop diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 8d8c4d70a..3630bb695 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -42,8 +42,10 @@ - + + + + \ No newline at end of file diff --git a/tests/ImageProcessor.Tests/ImageProcessor.Tests.csproj.DotSettings b/tests/ImageProcessor.Tests/ImageProcessor.Tests.csproj.DotSettings new file mode 100644 index 000000000..555fe0767 --- /dev/null +++ b/tests/ImageProcessor.Tests/ImageProcessor.Tests.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/tests/ImageProcessor.Tests/Numerics/PointTests.cs b/tests/ImageProcessor.Tests/Numerics/PointTests.cs new file mode 100644 index 000000000..0e45271f8 --- /dev/null +++ b/tests/ImageProcessor.Tests/Numerics/PointTests.cs @@ -0,0 +1,55 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright © James South and contributors. +// Licensed under the Apache License, Version 2.0. +// +// +// Tests the struct. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Tests +{ + using Xunit; + + /// + /// Tests the struct. + /// + public class PointTests + { + /// + /// Tests the equality operators for equality. + /// + [Fact] + public void AreEqual() + { + Point first = new Point(100, 100); + Point second = new Point(100, 100); + + Assert.Equal(first, second); + } + + /// + /// Tests the equality operators for inequality. + /// + [Fact] + public void AreNotEqual() + { + Point first = new Point(0, 100); + Point second = new Point(100, 100); + + Assert.NotEqual(first, second); + } + + /// + /// Tests whether the point constructor correctly assign properties. + /// + [Fact] + public void ConstructorAssignsProperties() + { + Point first = new Point(4, 5); + Assert.Equal(4, first.X); + Assert.Equal(5, first.Y); + } + } +} diff --git a/tests/ImageProcessor.Tests/Numerics/RectangleTests.cs b/tests/ImageProcessor.Tests/Numerics/RectangleTests.cs new file mode 100644 index 000000000..1ee16ea51 --- /dev/null +++ b/tests/ImageProcessor.Tests/Numerics/RectangleTests.cs @@ -0,0 +1,71 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright © James South and contributors. +// Licensed under the Apache License, Version 2.0. +// +// +// Tests the struct. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Tests +{ + using Xunit; + + /// + /// Tests the struct. + /// + public class RectangleTests + { + /// + /// Tests the equality operators for equality. + /// + [Fact] + public void AreEqual() + { + Rectangle first = new Rectangle(1, 1, 100, 100); + Rectangle second = new Rectangle(1, 1, 100, 100); + + Assert.Equal(first, second); + } + + /// + /// Tests the equality operators for inequality. + /// + [Fact] + public void AreNotEqual() + { + Rectangle first = new Rectangle(1, 1, 0, 100); + Rectangle second = new Rectangle(1, 1, 100, 100); + + Assert.NotEqual(first, second); + } + + /// + /// Tests whether the rectangle constructors correctly assign properties. + /// + [Fact] + public void ConstructorAssignsProperties() + { + Rectangle first = new Rectangle(1, 1, 50, 100); + Assert.Equal(1, first.X); + Assert.Equal(1, first.Y); + Assert.Equal(50, first.Width); + Assert.Equal(100, first.Height); + Assert.Equal(1, first.Top); + Assert.Equal(51, first.Right); + Assert.Equal(101, first.Bottom); + Assert.Equal(1, first.Left); + + Rectangle second = new Rectangle(new Point(1, 1), new Size(50, 100)); + Assert.Equal(1, second.X); + Assert.Equal(1, second.Y); + Assert.Equal(50, second.Width); + Assert.Equal(100, second.Height); + Assert.Equal(1, second.Top); + Assert.Equal(51, second.Right); + Assert.Equal(101, second.Bottom); + Assert.Equal(1, second.Left); + } + } +} diff --git a/tests/ImageProcessor.Tests/Numerics/SizeTests.cs b/tests/ImageProcessor.Tests/Numerics/SizeTests.cs new file mode 100644 index 000000000..e09cb6071 --- /dev/null +++ b/tests/ImageProcessor.Tests/Numerics/SizeTests.cs @@ -0,0 +1,55 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright © James South and contributors. +// Licensed under the Apache License, Version 2.0. +// +// +// Tests the struct. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Tests +{ + using Xunit; + + /// + /// Tests the struct. + /// + public class SizeTests + { + /// + /// Tests the equality operators for equality. + /// + [Fact] + public void AreEqual() + { + Size first = new Size(100, 100); + Size second = new Size(100, 100); + + Assert.Equal(first, second); + } + + /// + /// Tests the equality operators for inequality. + /// + [Fact] + public void AreNotEqual() + { + Size first = new Size(0, 100); + Size second = new Size(100, 100); + + Assert.NotEqual(first, second); + } + + /// + /// Tests whether the size constructor correctly assign properties. + /// + [Fact] + public void ConstructorAssignsProperties() + { + Size first = new Size(4, 5); + Assert.Equal(4, first.Width); + Assert.Equal(5, first.Height); + } + } +} diff --git a/tests/ImageProcessor.Tests/Properties/AssemblyInfo.cs b/tests/ImageProcessor.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..c0545090d --- /dev/null +++ b/tests/ImageProcessor.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("ImageProcessor.Tests")] +[assembly: AssemblyDescription("A library for on-the-fly processing of image files written in C#")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageProcessor")] +[assembly: AssemblyCopyright("Copyright © James South and contributors.")] +[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("8fea7d87-3f18-465a-b15f-abb1783c95bc")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/ImageProcessor.Tests/packages.config b/tests/ImageProcessor.Tests/packages.config new file mode 100644 index 000000000..3109db107 --- /dev/null +++ b/tests/ImageProcessor.Tests/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file