Skip to content
Snippets Groups Projects
Commit 0ab4728e authored by Riley Mcgee's avatar Riley Mcgee
Browse files

Merge branch 'UnitTest'

parents cb57b950 5eb39fbb
No related branches found
No related tags found
No related merge requests found

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gifitti", "Gifitti\Gifitti.csproj", "{07513F6B-9A44-4981-A3F9-8882AC8B890E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GifittiUnitTest", "GifittiUnitTest\GifittiUnitTest.csproj", "{AAD6F348-4321-4BB9-9EE7-0E07EF29B961}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -15,6 +17,10 @@ Global
{07513F6B-9A44-4981-A3F9-8882AC8B890E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07513F6B-9A44-4981-A3F9-8882AC8B890E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07513F6B-9A44-4981-A3F9-8882AC8B890E}.Release|Any CPU.Build.0 = Release|Any CPU
{AAD6F348-4321-4BB9-9EE7-0E07EF29B961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAD6F348-4321-4BB9-9EE7-0E07EF29B961}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAD6F348-4321-4BB9-9EE7-0E07EF29B961}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAD6F348-4321-4BB9-9EE7-0E07EF29B961}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -17,7 +17,7 @@ namespace Gifitti.Models
/// <summary>
/// Software model of a GIF, Encapsulated with bassic opperations on GIF images.
/// </summary>
class GifModel
public class GifModel
{
public Image gifImage { get; set; }
public Image originalGif { get; private set; }
......@@ -87,10 +87,8 @@ namespace Gifitti.Models
Regex extensionTester = new Regex(@"^.*\.[g|G][i|I][f|F]$");
//RE for path without extension
Regex savePathTester = new Regex(@"^((?:(?:[^\/\\]+)*[\/\\]*)*)[\/\\]([^\/\\]*)$");
if (!savePathTester.IsMatch(path) || !Directory.Exists(savePathTester.Match(path).Groups[1].ToString()))
{
throw new DirectoryNotFoundException();
}
//if (!savePathTester.IsMatch(path) || !Directory.Exists(savePathTester.Match(path).Groups[1].ToString()))
// throw new DirectoryNotFoundException();
//Handel non gif extensions
if (!extensionTester.IsMatch(path))
path += ".gif";
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AAD6F348-4321-4BB9-9EE7-0E07EF29B961}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GifittiUnitTest</RootNamespace>
<AssemblyName>GifittiUnitTest</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</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.Drawing" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
<Private>False</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Helper\UnitTestHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SubGif\SubGifUnitTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Gifitti\Gifitti.csproj">
<Project>{07513f6b-9a44-4981-a3f9-8882ac8b890e}</Project>
<Name>Gifitti</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="res\Input.gif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="res\SubInput_S10E16.gif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\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>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GifittiUnitTest.Helper
{
static class UnitTestHelper
{
public const string INPUT_GIF = @"res\Input.gif";
public const string SUB_GIF_EXPECTED = @"res\SubInput_S10E16.gif";
public static bool PxByPxCompare(Image a, Image b){
if ((a as Bitmap).Equals(b as Bitmap))
return true;
var aB = a as Bitmap;
var bB = b as Bitmap;
for(int i = 0; i < aB.Width; i++)
for(int j = 0; j < aB.Height; j++)
if (!aB.GetPixel(i, j).Equals(bB.GetPixel(i, j)))
return false;
//EQUAL IMAGES
return true;
}
}
}
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("GifittiUnitTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GifittiUnitTest")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("aad6f348-4321-4bb9-9ee7-0e07ef29b961")]
// 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")]
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Gifitti.Models;
using GifittiUnitTest.Helper;
namespace GifittiUnitTest.SubGif
{
[TestClass]
public class SubGifUnitTest
{
private const string TEMP_OUT = @"TEMP_GIF_SUB_GIF.gif";
[TestMethod]
public void SubGifValidation()
{
//Load GM model of Input
GifModel gmInput = new GifModel(UnitTestHelper.INPUT_GIF);
gmInput.startFrame = 10;
gmInput.endFrame = 16;
gmInput.saveGif(TEMP_OUT);
//Compare actual versus expected
GifModel gmExpected = new GifModel(UnitTestHelper.SUB_GIF_EXPECTED);
GifModel gmActual = new GifModel(TEMP_OUT);
if (gmExpected.numberOfFrames != gmActual.numberOfFrames)
Assert.Fail(@"# FRAMES MISMATCH");
for(int i = gmExpected.startFrame; i < gmExpected.numberOfFrames; i++)
{
if (!UnitTestHelper.PxByPxCompare(gmExpected.gifImage, gmActual.gifImage))
Assert.Fail(@"Failue on Frame {0}, NOT EQUAL", i);
}
//PASS
}
}
}
src/Gifitti/GifittiUnitTest/res/Input.gif

923 KiB

src/Gifitti/GifittiUnitTest/res/SubInput_S10E16.gif

58.8 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment