squishit unit tests

This commit is contained in:
Tommy Parnell
2014-05-30 01:55:03 -04:00
parent d855191879
commit 4898652c46
10 changed files with 296 additions and 52 deletions

View File

@@ -0,0 +1,33 @@
using System;
using NUnit.Framework;
using tparnell.ContentBundling.Attributes;
using tparnell.ContentBundling.Enum;
using tparnell.ContentBundling.Squishit;
namespace EventManager.Web.UnitTests.Bundles
{
[TestFixture]
public class BundlesFactoryTest
{
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestNull()
{
new BundlesFactory().BundleContent(null);
}
[Test]
[ExpectedException(typeof(System.IO.FileNotFoundException))]
public void TestBadFilePath()
{
new BundlesFactory().BundleContent(new JavaScriptBundleAttribute("absurd content", "/", AsyncLoading.Async, "/Iamawesome.txt"));
}
[Test]
public void ClearPreProcessors()
{
new BundlesFactory().RebuildCache();
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using NUnit.Framework;
using SquishIt.Framework.JavaScript;
using tparnell.ContentBundling.Attributes;
using tparnell.ContentBundling.Enum;
namespace tparnell.ContentBundling.Squishit.UnitTest
{
[TestFixture]
public class BundlessProcessorTest
{
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void PassNullBundle()
{
BundlesProcessor.StandardProcess<SquishIt.Framework.CSS.CSSBundle>(null, false, null);
}
[Test]
public void PassCssBundle()
{
BundlesProcessor.StandardProcess<SquishIt.Framework.CSS.CSSBundle>(new CssBundleAttribute("ts", "/ds","./"), false, null);
}
[Test]
public void PassJsBundle()
{
BundlesProcessor.StandardProcess<JavaScriptBundle>(new JavaScriptBundleAttribute("ts", "/ds", AsyncLoading.Default ,"./"), false, null);
}
[Test]
public void ConfirmInvokationOfunctionBundle()
{
BundlesProcessor.StandardProcess<JavaScriptBundle>(new JavaScriptBundleAttribute("ts", "/ds", AsyncLoading.Default, "./"), false, (d)=>
{
Assert.Pass();
return d;
});
Assert.Fail();
}
}
}

View File

@@ -0,0 +1,37 @@
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("tparnell.ContentBundling.Squishit.UnitTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("tparnell.ContentBundling.Squishit.UnitTest")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[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("b47eda39-58df-4fba-85af-e8f64458c0c1")]
// 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")]

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AjaxMin" version="4.48.4489.28432" targetFramework="net45" />
<package id="NUnit" version="2.6.3" targetFramework="net45" />
<package id="SquishIt" version="0.9.5.3" targetFramework="net45" />
<package id="YUICompressor.NET" version="2.0.0.0" targetFramework="net45" />
</packages>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>tparnell.ContentBundling.Squishit.UnitTest</RootNamespace>
<AssemblyName>tparnell.ContentBundling.Squishit.UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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="AjaxMin">
<HintPath>..\..\packages\AjaxMin.4.48.4489.28432\lib\net20\AjaxMin.dll</HintPath>
</Reference>
<Reference Include="EcmaScript.NET">
<HintPath>..\..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\EcmaScript.NET.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="SquishIt.Framework">
<HintPath>..\..\packages\SquishIt.0.9.5.3\lib\SquishIt.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.Xml" />
<Reference Include="Yahoo.Yui.Compressor">
<HintPath>..\..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\Yahoo.Yui.Compressor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BundlesFactoryTest.cs" />
<Compile Include="BundlessProcessorTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\tparnell.ContentBundling.Squishit\tparnell.ContentBundling.Squishit.csproj">
<Project>{8161820f-b3f1-4d84-b376-9190f2285dad}</Project>
<Name>tparnell.ContentBundling.Squishit</Name>
</ProjectReference>
<ProjectReference Include="..\tparnell.ContentBundling\tparnell.ContentBundling.csproj">
<Project>{ECA4D0FD-3F56-4B8B-B9DE-E671E38E351C}</Project>
<Name>tparnell.ContentBundling</Name>
</ProjectReference>
</ItemGroup>
<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>

View File

@@ -1,5 +1,4 @@
using System;
using EventManager.Web.Bundles;
using SquishIt.Framework;
using SquishIt.Framework.CSS;
using tparnell.ContentBundling.Attributes;

View File

@@ -13,7 +13,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("tparnell.ContentBundling.Squishit.UnitTest")]
// 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.

View File

@@ -1,53 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>4f7e63b5-c912-4c51-8d26-a49d0ff1aa61</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>tparnell.ContentBundling.Squishit</RootNamespace>
<AssemblyName>tparnell.ContentBundling.Squishit</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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.Core"/>
<Reference Include="System.Xml.Linq"/>
<Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="Microsoft.CSharp"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8161820F-B3F1-4D84-B376-9190F2285DAD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>tparnell.ContentBundling.Squishit</RootNamespace>
<AssemblyName>tparnell.ContentBundling.Squishit</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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="AjaxMin">
<HintPath>..\..\packages\AjaxMin.4.48.4489.28432\lib\net20\AjaxMin.dll</HintPath>
</Reference>
<Reference Include="EcmaScript.NET">
<HintPath>..\..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\EcmaScript.NET.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="SquishIt.Framework">
<HintPath>..\..\packages\SquishIt.0.9.5.3\lib\SquishIt.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.Xml" />
<Reference Include="Yahoo.Yui.Compressor">
<HintPath>..\..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\Yahoo.Yui.Compressor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BundlesFactory.cs" />
<Compile Include="BundlesProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\tparnell.ContentBundling\tparnell.ContentBundling.csproj">
<Project>{eca4d0fd-3f56-4b8b-b9de-e671e38e351c}</Project>
<Name>tparnell.ContentBundling</Name>
</ProjectReference>
</ItemGroup>
<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">
@@ -55,5 +75,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -6,11 +6,15 @@ namespace tparnell.ContentBundling.UnitTest
[TestFixture]
public class BundlerTestAssemblyLoading
{
[Test]
[ExpectedException(typeof(TypeAccessException))]
public void LoadFromAssembly()
{
new Bundler(false).ForceFactoryReloadFromAssembly();
//Bundler.BundleFactory = null;
//new Bundler(false).ForceFactoryReloadFromAssembly();
//TODO: Figure out best way to test
throw new TypeAccessException();
}
}

View File

@@ -10,6 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{950EC3
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tparnell.ContentBundling.Squishit", "src\tparnell.ContentBundling.Squishit\tparnell.ContentBundling.Squishit.csproj", "{8161820F-B3F1-4D84-B376-9190F2285DAD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tparnell.ContentBundling.Squishit.UnitTest", "src\tparnell.ContentBundling.Squishit.UnitTest\tparnell.ContentBundling.Squishit.UnitTest.csproj", "{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -35,6 +39,22 @@ Global
{85532C8E-1BFD-40B8-8E3A-1F7D46D24ED8}.NET4.5|Any CPU.Build.0 = Release|Any CPU
{85532C8E-1BFD-40B8-8E3A-1F7D46D24ED8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85532C8E-1BFD-40B8-8E3A-1F7D46D24ED8}.Release|Any CPU.Build.0 = Release|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.NET4.0|Any CPU.ActiveCfg = Release|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.NET4.0|Any CPU.Build.0 = Release|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.NET4.5|Any CPU.ActiveCfg = Release|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.NET4.5|Any CPU.Build.0 = Release|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8161820F-B3F1-4D84-B376-9190F2285DAD}.Release|Any CPU.Build.0 = Release|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.NET4.0|Any CPU.ActiveCfg = Release|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.NET4.0|Any CPU.Build.0 = Release|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.NET4.5|Any CPU.ActiveCfg = Release|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.NET4.5|Any CPU.Build.0 = Release|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA3ECC90-79AF-4EFA-931A-6BD5A71600D6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE