Skip to content

Commit 195eaa9

Browse files
author
dotnetnerd
committed
Moved over from bitbucket
1 parent 60838ca commit 195eaa9

File tree

180 files changed

+90536
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+90536
-4
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Oo]bj
2+
[Bb]in
3+
[Pp]ackages
4+
*.user
5+
*.nupkg
6+
*.suo
7+
*.[Cc]ache
8+
*.bak
9+
*.ncb
10+
*.log
11+
*.DS_Store
12+
[Tt]humbs.db
13+
_ReSharper.*
14+
*.resharper
15+
Ankh.NoLoad
16+
*.ncrunchsolution
17+
*.ncrunchsolution.cache
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using MiniMe.CoffeeScript;
4+
using MiniMe.Test.Common;
5+
using NUnit.Framework;
6+
using Rhino.Mocks;
7+
8+
namespace MiniMe.Test.CoffeeScript
9+
{
10+
[TestFixture]
11+
public class MiniCoffeeScriptBuilderTester : BaseBuilderTester
12+
{
13+
[Test]
14+
public void Render_OutputsTag_ReturnesCorrectTag()
15+
{
16+
const string jsPath = "/Content/test.js",
17+
cssUnversionedRelativePath = "/content/site_#.js",
18+
tag = "<script src=\"/Content/test.js\"></script>\r\n";
19+
20+
HttpRequest.Stub(r => r.IsLocal).Return(false);
21+
HttpContext.Stub(c => c.IsDebuggingEnabled).Return(true);
22+
23+
var subject = new MiniCoffeeScriptBuilder(HttpContext, new Mini(), FileSystem);
24+
var result = subject.Add(jsPath).Render(cssUnversionedRelativePath);
25+
Assert.That(result, Is.EqualTo(tag));
26+
}
27+
28+
[Test]
29+
public void Render_WritesCombinedFile_FileIsWritten()
30+
{
31+
const string jsPath = "/Content/test.js",
32+
cssUnversionedRelativePath = "/Content/site_#.js",
33+
jsVersionedRelativePath = "/Content/site_1655544483.js",
34+
jsVersionedFullPath = "c:\\Content/site_1655544483.js",
35+
coffeeVersionedFullPath = "c:\\Content/site_1655544483.coffee",
36+
fileContent = "Hmm";
37+
38+
HttpRequest.Stub(r => r.IsLocal).Return(false);
39+
HttpContext.Stub(c => c.IsDebuggingEnabled).Return(false);
40+
41+
Server.Stub(s => s.MapPath(jsVersionedRelativePath)).Return(jsVersionedFullPath);
42+
43+
FileSystem.Stub(f => f.GetExistingFiles(new List<string>()))
44+
.Return(new FileInfo[] { new FileInfo(jsPath) }).IgnoreArguments();
45+
46+
FileSystem.Stub(f => f.ReadAllText("")).Return(fileContent).IgnoreArguments();
47+
48+
var subject = new MiniCoffeeScriptBuilder(HttpContext, new Mini(), FileSystem);
49+
subject.ReRenders.Always().Add(jsPath).Render(cssUnversionedRelativePath);
50+
FileSystem.AssertWasCalled(f => f.WriteAllText(coffeeVersionedFullPath, fileContent + "\r\n"));
51+
}
52+
}
53+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections;
2+
using System.Web;
3+
using MiniMe.Common;
4+
using NUnit.Framework;
5+
using Rhino.Mocks;
6+
7+
namespace MiniMe.Test.Common
8+
{
9+
public abstract class BaseBuilderTester
10+
{
11+
protected HttpContextBase HttpContext;
12+
protected HttpRequestBase HttpRequest;
13+
protected HttpServerUtilityBase Server;
14+
protected IFileSystem FileSystem;
15+
protected IDictionary Dictionary;
16+
protected IMini Mini;
17+
protected ICache Cache;
18+
19+
[SetUp]
20+
public void Setup()
21+
{
22+
HttpContext = MockRepository.GenerateStub<HttpContextBase>();
23+
HttpRequest = MockRepository.GenerateStub<HttpRequestBase>();
24+
Server = MockRepository.GenerateMock<HttpServerUtilityBase>();
25+
FileSystem = MockRepository.GenerateMock<IFileSystem>();
26+
Dictionary = MockRepository.GenerateStub<IDictionary>();
27+
Cache = MockRepository.GenerateStub<ICache>();
28+
Mini = MockRepository.GenerateStub<IMini>();
29+
30+
HttpContext.Stub(c => c.Request).Return(HttpRequest);
31+
HttpContext.Stub(c => c.Items).Return(Dictionary);
32+
33+
HttpContext.Stub(c => c.Server).Return(Server);
34+
}
35+
}
36+
}

MiniMe.Test/Common/CacheMock.cs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web.Caching;
4+
using MiniMe.Common;
5+
6+
namespace MiniMe.Test.Common
7+
{
8+
class CacheMock : ICache
9+
{
10+
private static readonly Dictionary<string, object> _dictionary = new Dictionary<string, object>();
11+
public object Get(string key)
12+
{
13+
return _dictionary.ContainsKey(key) ? _dictionary[key] : null;
14+
}
15+
16+
public void Insert(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration)
17+
{
18+
if(_dictionary.ContainsKey(key))
19+
{
20+
_dictionary[key] = value;
21+
}
22+
else
23+
{
24+
_dictionary.Add(key, value);
25+
}
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using MiniMe.JavaScript;
4+
using MiniMe.Test.Common;
5+
using NUnit.Framework;
6+
using Rhino.Mocks;
7+
8+
namespace MiniMe.Test.JavaScript
9+
{
10+
[TestFixture]
11+
public class MiniJavaScriptBuilderTester : BaseBuilderTester
12+
{
13+
[Test]
14+
public void Render_OutputsTag_ReturnesCorrectTag()
15+
{
16+
const string jsPath = "/Content/test.js",
17+
cssUnversionedRelativePath = "/content/site_#.js",
18+
tag = "<script src=\"/Content/test.js\"></script>\r\n";
19+
20+
HttpRequest.Stub(r => r.IsLocal).Return(false);
21+
HttpContext.Stub(c => c.IsDebuggingEnabled).Return(true);
22+
23+
24+
var subject = new MiniJavaScriptBuilder(HttpContext, new Mini(), FileSystem, new CacheMock());
25+
var result = subject.Add(jsPath).Render(cssUnversionedRelativePath);
26+
Assert.That(result, Is.EqualTo(tag));
27+
}
28+
29+
[Test]
30+
public void Render_WritesCombinedFile_FileIsWritten()
31+
{
32+
const string jsPath = "/Content/test.js",
33+
jsUnversionedRelativePath = "/Content/site_#.js",
34+
jsVersionedRelativePath = "/Content/site_92223734.js",
35+
jsVersionedFullPath = "c:\\Content/site_92223734.js",
36+
fileContent = "Hmm";
37+
38+
HttpRequest.Stub(r => r.IsLocal).Return(false);
39+
HttpContext.Stub(c => c.IsDebuggingEnabled).Return(false);
40+
41+
Server.Stub(s => s.MapPath(jsVersionedRelativePath)).Return(jsVersionedFullPath);
42+
43+
FileSystem.Stub(f => f.GetExistingFiles(new List<string>()))
44+
.Return(new FileInfo[] { new FileInfo(jsPath) }).IgnoreArguments();
45+
46+
FileSystem.Stub(f => f.ReadAllText("")).Return(fileContent).IgnoreArguments();
47+
48+
var subject = new MiniJavaScriptBuilder(HttpContext, new Mini(FileSystem), FileSystem, new CacheMock());
49+
subject.ReRenders.Always().Add(jsPath).Render(jsUnversionedRelativePath);
50+
FileSystem.AssertWasCalled(f => f.WriteAllText(jsVersionedFullPath, fileContent + ";\r\n"));
51+
}
52+
53+
[Test]
54+
public void Render_SameInputDifferentOutput_RendersBothOutputs()
55+
{
56+
const string jsPath = "/Content/test.js",
57+
outputFile1 = "/Content/#/js1.js",
58+
outputFile2 = "/Content/#/js2.js",
59+
jsVersionedRelativePath1 = "/Content/92223734/js1.js",
60+
jsVersionedFullPath1 = "c:\\Content/92223734/js1.js",
61+
jsVersionedRelativePath2 = "/Content/92223734/js2.js",
62+
jsVersionedFullPath2 = "c:\\Content/92223734/js2.js",
63+
fileContent = "Hmm";
64+
65+
HttpRequest.Stub(r => r.IsLocal).Return(false);
66+
HttpContext.Stub(c => c.IsDebuggingEnabled).Return(false);
67+
68+
Server.Stub(s => s.MapPath(jsVersionedRelativePath1)).Return(jsVersionedFullPath1);
69+
Server.Stub(s => s.MapPath(jsVersionedRelativePath2)).Return(jsVersionedFullPath2);
70+
71+
FileSystem.Stub(f => f.GetExistingFiles(new List<string>()))
72+
.Return(new FileInfo[] { new FileInfo(jsPath) }).IgnoreArguments();
73+
74+
FileSystem.Stub(f => f.ReadAllText("")).Return(fileContent).IgnoreArguments();
75+
76+
var subject = new MiniJavaScriptBuilder(HttpContext, new Mini(FileSystem), FileSystem, new CacheMock());
77+
subject.ReRenders.Never().Add(jsPath).Render(outputFile1);
78+
subject.ReRenders.Never().Add(jsPath).Render(outputFile2);
79+
80+
81+
FileSystem.AssertWasCalled(f => f.WriteAllText(jsVersionedFullPath1, fileContent + ";\r\n"));
82+
FileSystem.AssertWasCalled(f => f.WriteAllText(jsVersionedFullPath2, fileContent + ";\r\n"));
83+
}
84+
}
85+
}

MiniMe.Test/MiniMe.Test.csproj

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{FF6D254A-B4DC-436B-8686-E7553004170E}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>MiniMe.Test</RootNamespace>
12+
<AssemblyName>MiniMe.Test</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="nunit.framework">
35+
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
36+
</Reference>
37+
<Reference Include="nunit.mocks">
38+
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
39+
</Reference>
40+
<Reference Include="pnunit.framework">
41+
<HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
42+
</Reference>
43+
<Reference Include="Rhino.Mocks">
44+
<HintPath>..\packages\RhinoMocks.3.6\lib\Rhino.Mocks.dll</HintPath>
45+
</Reference>
46+
<Reference Include="System" />
47+
<Reference Include="System.Core" />
48+
<Reference Include="System.Web" />
49+
<Reference Include="System.Web.Abstractions" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Xml" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Compile Include="CoffeeScript\MiniCoffeeScriptBuilderTester.cs" />
58+
<Compile Include="Common\BaseBuilderTester.cs" />
59+
<Compile Include="Common\CacheMock.cs" />
60+
<Compile Include="JavaScript\MiniJavaScriptBuilderTester.cs" />
61+
<Compile Include="Properties\AssemblyInfo.cs" />
62+
<Compile Include="Scss\MiniScssBuilderTester.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="packages.config" />
66+
</ItemGroup>
67+
<ItemGroup>
68+
<ProjectReference Include="..\MiniMe\MiniMe.csproj">
69+
<Project>{7F543C50-41DF-4739-B2C0-F6291360A36D}</Project>
70+
<Name>MiniMe</Name>
71+
</ProjectReference>
72+
</ItemGroup>
73+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
74+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
75+
Other similar extension points exist, see Microsoft.Common.targets.
76+
<Target Name="BeforeBuild">
77+
</Target>
78+
<Target Name="AfterBuild">
79+
</Target>
80+
-->
81+
</Project>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<ProjectConfiguration>
2+
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
3+
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
4+
<AllowCodeContractChecking>false</AllowCodeContractChecking>
5+
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
6+
<RunPreBuildEvents>false</RunPreBuildEvents>
7+
<RunPostBuildEvents>false</RunPostBuildEvents>
8+
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
9+
<InstrumentAssembly>true</InstrumentAssembly>
10+
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
11+
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
12+
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
13+
<DefaultTestTimeout>60000</DefaultTestTimeout>
14+
<UseBuildConfiguration />
15+
<ProxyProcessPath />
16+
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
17+
</ProjectConfiguration>
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("MiniMe.Test")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("MiniMe.Test")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("4b6cc4bc-f653-45fd-a557-9b29ee77e223")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)