-
Notifications
You must be signed in to change notification settings - Fork 21
Implemented ShouldRenderFileStream. #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1d55cb0
6aec7fa
08e275b
ba97591
adf9091
c87a3d7
7484d73
6df127c
3ffd3c0
fddfd5f
be16de5
f641439
e94f489
253b065
c2b7d52
b242945
bc9ca73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Version 2.0.0 | ||
|
||
## ShouldRenderFileStream Method | ||
|
||
The following overload of the `ShouldRenderFileStream` method has been *replaced*: | ||
|
||
public FileStreamResult ShouldRenderFileStream(string contentType = null) | ||
|
||
We place emphasis on the word "replace" because it is important to note that this overload has not been removed but replaced - you will not encounter a compile-time error if you upgrade, but you will encounter a logical error when you run your existing test. | ||
|
||
### Reason | ||
|
||
The aforementioned overload has been replaced in order to enable an overload that takes a stream for comparison in a way that is consistent with the existing convention. | ||
|
||
### Fix | ||
|
||
Use a [named argument](http://msdn.microsoft.com/en-gb/library/dd264739.aspx). | ||
|
||
As where you would have previously done this: | ||
|
||
ShouldRenderFileStream("application/json"); | ||
|
||
You must now do this: | ||
|
||
ShouldRenderFileStream(contentType: "application/json"); | ||
|
||
|
||
## ShouldRenderFileMethod | ||
|
||
The `ShouldRenderFile` method has been removed. | ||
|
||
### Reason | ||
|
||
The `ShouldRenderFile` method was ambiguous because it had the possibility to be interperted to test for a `FileResult` when in fact, it tested for a `FileContentResult`. | ||
|
||
It is for this reason that we introduced two unequivocal methods namely, `ShouldRenderAnyFile` and `ShouldRenderFileContents`. | ||
|
||
### Fix | ||
|
||
Use the `ShouldRenderFileContents` method instead: | ||
|
||
ShouldRenderAnyFile() | ||
ShouldRenderAnyFile(contentType: "application/json") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.1.0 | ||
2.0.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my first time practicing Semantic Versioning. If I understood correctly, a breaking change (see BREAKING_CHANGES.MD) no matter how small should result in the major version being bumped and a major version bump results in the minor and patch versions being reset to 0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct :) While we are at it let's delete that method we marked Also, we should have a think if there are any other breaking changes we want to make so they can all be made at once. Also, having a
Let me know if this doesn't make sense and I'll try and explain better :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is some good thinking man.
So I added a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd link it between the projects yeah, let me know when it's pushed and I'll check it. Pretty sure what you have above is right. You can download nuget.exe and run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the tip. I think I confirmed that the aforementioned path: In hindsight that path clearly won't work for the Mvc3 project because linked files are not copied to the physical directory. We could use MSBuild to change that I guess? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is not quite correct but I think I got it. Check out the latest push, I think are good now. Let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep looks good! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,8 +94,8 @@ | |
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="FluentMVCTesting.Mvc3.nuspec" /> | ||
<None Include="packages.config" /> | ||
<None Include="TestStack.FluentMVCTesting.Mvc3.nuspec" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI These changes were a good candidate for a separate PR since it's a separate logical change and could be merged in a lot quicker since it's such a simple change. No big deal though - it's already in here, just good food for thought :) by the way - if you get a spare moment at some point feel free to check out my presentation about pull requests: https://github.com/robdmoore/PushBetterSoftwareWithPullRequestsPresentation It's focussed on commercial development, but there are still some good general tips in there :) |
||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
|
@@ -105,4 +105,4 @@ | |
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> | ||
</Project> |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,11 @@ class ControllerResultTestController : Controller | |
public const string JsonValue = "json"; | ||
public const string FileName = "NamedFile"; | ||
public static byte[] BinaryFileContents = { 1 }; | ||
public static string TextualFileContents = "textual content"; | ||
public static string TextualFileContent = "textual content"; | ||
public static byte[] EmptyFileBuffer = { }; | ||
public static readonly Stream EmptyStreamContents = new MemoryStream(EmptyFileBuffer); | ||
public static readonly Stream BinaryStreamContents = new MemoryStream(BinaryFileContents); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not really too concerned about this anymore, but I did notice that because these types have internal state (unlike constant primitive types) they can cause test pollution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you mean by test pollution in this case? |
||
|
||
#endregion | ||
|
||
#region Empty, Null and Random Results | ||
|
@@ -174,14 +178,30 @@ public ActionResult TextualFile() | |
|
||
public ActionResult TextualFile(Encoding encoding) | ||
{ | ||
var encodedContents = encoding.GetBytes(TextualFileContents); | ||
var encodedContents = encoding.GetBytes(TextualFileContent); | ||
return File(encodedContents, FileContentType); | ||
} | ||
|
||
public ActionResult EmptyStream() | ||
{ | ||
var content = new MemoryStream(); | ||
return File(content, FileContentType); | ||
return File(EmptyStreamContents, FileContentType); | ||
} | ||
|
||
public ActionResult BinaryStream() | ||
{ | ||
return File(BinaryStreamContents, FileContentType); | ||
} | ||
|
||
public ActionResult TextualStream() | ||
{ | ||
return TextualStream(Encoding.UTF8); | ||
} | ||
|
||
public ActionResult TextualStream(Encoding encoding) | ||
{ | ||
var encondedContent = encoding.GetBytes(TextualFileContent); | ||
var stream = new MemoryStream(encondedContent); | ||
return File(stream, FileContentType); | ||
} | ||
|
||
public ActionResult EmptyFilePath() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FluentMVCTesting | ||
============== | ||
|
||
* For the project homepage including the current README, see https://github.com/TestStack/TestStack.FluentMVCTesting | ||
* To check for potential breaking changes in this release, see https://github.com/TestStack/TestStack.FluentMVCTesting/blob/master/BREAKING_CHANGES.md | ||
* If you need to raise an issue or check for an existing issue, see https://github.com/TestStack/TestStack.FluentMVCTesting/issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Might be worth mentioning the other ShouldRenferFile* methods here for completeness.