Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jim Counts
committed
Dec 6, 2014
1 parent
6c44a4f
commit 45f3c68
Showing
11 changed files
with
275 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,74 @@ | ||
using System.Collections.Specialized; | ||
|
||
using ApprovalTests.Asp; | ||
using ApprovalTests.Asp.Mvc; | ||
using ApprovalTests.Reporters; | ||
|
||
using CassiniDev; | ||
|
||
using MvcApplication1; | ||
using MvcApplication1.Controllers; | ||
using MvcApplication1.Models; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace ApprovalTests.Tests.Asp.Mvc | ||
{ | ||
public class MvcTest | ||
{ | ||
[TestFixture] | ||
[UseReporter(typeof (TortoiseDiffReporter), typeof (AllFailingTestsClipboardReporter))] | ||
public class TryingMvcViewApproval | ||
{ | ||
private CassiniDevServer server = new CassiniDevServer(); | ||
|
||
[TestFixtureSetUp] | ||
public void Setup() | ||
{ | ||
PortFactory.MvcPort = 11624; | ||
server.StartServer(MvcApplication.Path, PortFactory.MvcPort, "/", "localhost"); | ||
} | ||
public class MvcTest | ||
{ | ||
[TestFixture] | ||
[UseReporter(typeof(DiffReporter), typeof(AllFailingTestsClipboardReporter))] | ||
public class TryingMvcViewApproval | ||
{ | ||
private readonly CassiniDevServer server = new CassiniDevServer(); | ||
|
||
[TestFixtureTearDown] | ||
public void TearDown() | ||
{ | ||
server.StopServer(); | ||
} | ||
[TestFixtureSetUp] | ||
public void Setup() | ||
{ | ||
PortFactory.MvcPort = 11624; | ||
this.server.StartServer(MvcApplication.Path, PortFactory.MvcPort, "/", "localhost"); | ||
} | ||
|
||
[TestFixtureTearDown] | ||
public void TearDown() | ||
{ | ||
this.server.StopServer(); | ||
} | ||
|
||
[Test] | ||
public void TestingSomeMvcView() | ||
{ | ||
//AspApprovals.VerifyUrlViaPost("http://localhost:11624/Cool/Index"); | ||
MvcApprovals.VerifyMvcPage(new CoolController().Index); | ||
} | ||
[Test] | ||
public void TestingSomeMvcView() | ||
{ | ||
// AspApprovals.VerifyUrlViaPost("http://localhost:11624/Cool/Index"); | ||
MvcApprovals.VerifyMvcPage(new CoolController().Index); | ||
} | ||
|
||
[Test] | ||
public void TestingPostView() | ||
{ | ||
MvcApprovals.VerifyUrlViaPost("http://localhost:11624/Cool/SaveName", new NameValueCollection {{"Name", "Henrik"}}); | ||
} | ||
[Test] | ||
public void TestingPostView() | ||
{ | ||
MvcApprovals.VerifyUrlViaPost("http://localhost:11624/Cool/SaveName", new NameValueCollection { { "Name", "Henrik" } }); | ||
} | ||
|
||
[Test] | ||
public void TestingMvcWithPost() | ||
{ | ||
MvcApprovals.VerifyMvcViaPost<Person>(new CoolController().SaveName, new NameValueCollection {{"Name", "Henrik"}}); | ||
} | ||
[Test] | ||
public void TestingMvcWithPost() | ||
{ | ||
MvcApprovals.VerifyMvcViaPost<Person>(new CoolController().SaveName, new NameValueCollection { { "Name", "Henrik" } }); | ||
} | ||
|
||
[Test] | ||
public void TestingMvcWithPost2() | ||
{ | ||
MvcApprovals.VerifyMvcViaPost<Person>(new CoolController().SaveName, new Person {Name = "Henrik"}); | ||
} | ||
[Test] | ||
public void TestingMvcWithPost2() | ||
{ | ||
MvcApprovals.VerifyMvcViaPost(new CoolController().SaveName, new Person { Name = "Henrik" }); | ||
} | ||
|
||
# if DEBUG | ||
#if DEBUG | ||
|
||
[Test] | ||
public void TestWithName() | ||
{ | ||
MvcApprovals.VerifyMvcPage(new CoolController().TestName); | ||
} | ||
[Test] | ||
public void TestWithName() | ||
{ | ||
MvcApprovals.VerifyMvcPage(new CoolController().TestName); | ||
} | ||
|
||
#endif | ||
} | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
ApprovalTests.Tests/Asp/Mvc/TryingMvcViewApproval.TestingMvcWithPost.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ApprovalTests.Tests/Asp/Mvc/TryingMvcViewApproval.TestingMvcWithPost2.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ApprovalTests.Tests/Asp/Mvc/TryingMvcViewApproval.TestingPostView.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 55 additions & 57 deletions
112
ApprovalTests.Tests/Reporters/GenericDiffReporterTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,70 @@ | ||
using System.IO; | ||
using ApprovalTests.Reporters; | ||
using ApprovalUtilities.Utilities; | ||
using NUnit.Framework; | ||
using System.IO; | ||
|
||
namespace ApprovalTests.Tests.Reporters | ||
{ | ||
[TestFixture] | ||
public class GenericDiffReporterTest | ||
{ | ||
[Test] | ||
public void TestGetActualProgramFileEchos() | ||
{ | ||
string NoneExistingFile = @"C:\ThisDirectoryShouldNotExist\ThisFileShouldNotExist.exe"; | ||
Assert.AreEqual(NoneExistingFile, GenericDiffReporter.GetActualProgramFile(NoneExistingFile)); | ||
} | ||
|
||
[Test] | ||
public void TestGetCurrentProject() | ||
{ | ||
var file = PathUtilities.GetAdjacentFile("GenericDiffReporterTest.TestLaunchesBeyondCompareImage.approved.txt"); | ||
string currentProjectFile = Path.GetFileName(VisualStudioProjectFileAdder.GetCurrentProjectFile(file)); | ||
|
||
Assert.AreEqual("ApprovalTests.Tests.csproj", currentProjectFile); | ||
} | ||
[TestFixture] | ||
public class GenericDiffReporterTest | ||
{ | ||
[Test] | ||
public void TestGetActualProgramFileEchos() | ||
{ | ||
string NoneExistingFile = @"C:\ThisDirectoryShouldNotExist\ThisFileShouldNotExist.exe"; | ||
Assert.AreEqual(NoneExistingFile, GenericDiffReporter.GetActualProgramFile(NoneExistingFile)); | ||
} | ||
|
||
[Test] | ||
public void TestGetCurrentProjectNotFound() | ||
{ | ||
var project = VisualStudioProjectFileAdder.GetCurrentProjectFile("C:\\"); | ||
[Test] | ||
public void TestGetCurrentProject() | ||
{ | ||
var file = PathUtilities.GetAdjacentFile("GenericDiffReporterTest.TestLaunchesBeyondCompareImage.approved.txt"); | ||
string currentProjectFile = Path.GetFileName(VisualStudioProjectFileAdder.GetCurrentProjectFile(file)); | ||
|
||
Assert.AreEqual(null, project); | ||
} | ||
Assert.AreEqual("ApprovalTests.Tests.csproj", currentProjectFile); | ||
} | ||
|
||
[Test] | ||
public void TestGetCurrentProjectNotFound() | ||
{ | ||
var project = VisualStudioProjectFileAdder.GetCurrentProjectFile("C:\\"); | ||
|
||
[Test] | ||
public void TestMissingDots() | ||
{ | ||
var e = | ||
ExceptionUtilities.GetException(() => GenericDiffReporter.RegisterTextFileTypes(".exe", "txt", ".error", "asp")); | ||
Approvals.Verify(e); | ||
} | ||
Assert.AreEqual(null, project); | ||
} | ||
|
||
[Test] | ||
public void TestProgramsExist() | ||
{ | ||
Assert.IsFalse(new GenericDiffReporter("this_should_never_exist", "").IsWorkingInThisEnvironment("any.txt")); | ||
} | ||
[Test] | ||
public void TestMissingDots() | ||
{ | ||
var e = | ||
ExceptionUtilities.GetException(() => GenericDiffReporter.RegisterTextFileTypes(".exe", "txt", ".error", "asp")); | ||
Approvals.Verify(e); | ||
} | ||
|
||
[Test] | ||
public void TestRegisterWorks() | ||
{ | ||
var r = new TortoiseDiffReporter(); | ||
GenericDiffReporter.RegisterTextFileTypes(".myCrazyExtension"); | ||
Assert.IsTrue(r.IsWorkingInThisEnvironment("file.myCrazyExtension")); | ||
} | ||
[Test] | ||
public void TestProgramsExist() | ||
{ | ||
Assert.IsFalse(new GenericDiffReporter("this_should_never_exist", "").IsWorkingInThisEnvironment("any.txt")); | ||
} | ||
|
||
[Test] | ||
public void TestRegisterWorks() | ||
{ | ||
var r = new CodeCompareReporter(); | ||
GenericDiffReporter.RegisterTextFileTypes(".myCrazyExtension"); | ||
Assert.IsTrue(r.IsWorkingInThisEnvironment("file.myCrazyExtension")); | ||
} | ||
|
||
[Test] | ||
[UseReporter(typeof (ClipboardReporter))] | ||
public void TestEnsureFileExist() | ||
{ | ||
var imageFile = PathUtilities.GetAdjacentFile("TestImage.png"); | ||
if (File.Exists(imageFile)) | ||
{ | ||
File.Delete(imageFile); | ||
} | ||
GenericDiffReporter.EnsureFileExists(imageFile); | ||
Approvals.VerifyFile(imageFile); | ||
} | ||
} | ||
[Test] | ||
[UseReporter(typeof(ClipboardReporter))] | ||
public void TestEnsureFileExist() | ||
{ | ||
var imageFile = PathUtilities.GetAdjacentFile("TestImage.png"); | ||
if (File.Exists(imageFile)) | ||
{ | ||
File.Delete(imageFile); | ||
} | ||
GenericDiffReporter.EnsureFileExists(imageFile); | ||
Approvals.VerifyFile(imageFile); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.