Technorati Tags: Unit Testing,MVC,VS 2010
I have a view that really only provides content, is there a quick way to test that it exists? What’s the Assert?
There’s really not much to unit test if you have a page that has only HTML in a MVC (Model-View-Controller) project. And to some extent, if you had a test [...]
Posts Tagged ‘Unit Testing’
Unit Testing a Very Simple ViewResult in MVC
Filed under: Technology | Tags: MVC, Unit Testing, VS 2010
Unit Testing CodeSmith Insight
Filed under: Technology | Tags: CodeSmith, Insight, Moq, MVC, Unit Testing
Technorati Tags: Unit Testing,MVC,Moq,CodeSmith,Insight
As anyone that knows me knows, I use test driven development. So when I put together a Feedback page in my MVC (Model-View-Controller) site I started with my test. What should the test be?
Let’s start with the User Story : As a site user (anonymous or logged in) I want to submit [...]
Unit Test Authorize Attribute
Filed under: Technology | Tags: ASP.NET, MVC, Unit Testing, VS 2010
Technorati Tags: Unit Testing,ASP.NET,MVC,VS 2010
Story: I want to write a unit test to ensure that the Authorize attribute is applied to a controller ActionResult or ViewResult so that security is tested.
Here is the test:
Unit Test
[TestMethod]
public void PreviousSiteUserConversion_Authorization_Attributes_Have_Been_Applied()
{
// Arrange
MethodInfo varietalMethod = typeof(AdminController).GetMethod("PreviousSiteUserConversion", new Type[] { });
// Act
var attributes = varietalMethod.GetCustomAttributes(typeof(AuthorizeAttribute), true);
// Assert
Assert.IsNotNull(attributes);
Assert.AreEqual(1, attributes.Length);
var authAttribute = (AuthorizeAttribute)attributes[0];
string[] [...]
MVC – The Start
Filed under: Technology | Tags: ASP.NET, Code Analysis, MVC, Unit Testing
Technorati Tags: ASP.NET,MVC,Code Analysis,Unit Testing
This shows my initial setup of an MVC 2 RC 2 application. Using Visual Studio 2010 RC I selected File –> New –> Project… then under Visual C#, Web, I selected the ASP.NET MVC 2 Web Application.
Then when I click OK I get the following dialog. Since I’m a very [...]
Testing HtmlHelper in MVC 2 RC 2
Filed under: Technology | Tags: ASP.NET, Moq, MVC, TDD, Unit Testing
Technorati Tags: MVC,TDD,Mock,Moq
I strive to use TDD (Test Driven Development) so not having unit tests drives me crazy. I was so pleased to run across this post http://ox.no/posts/mocking-htmlhelper-in-aspnet-mvc-rc1-using-moq making it easy for me to unit test the Html Helper.
But then I downloaded the MVC 2 RC 2 and all my unit tests for HtmlHelper broke! [...]
Saturday Night Wrestling with MVC
Filed under: Technology | Tags: ASP.NET, EF, MVC, Unit Testing, VS 2010
Ok… It wasn’t really that bad, but it did take some effort. Here was my objective: Now that MVC (ASP.NET Model-View-Controller) 1.1 has been released (not sure how I missed that) to work with Visual Studio 2010 and .NET 4.0 migrate my evolving website to use the .NET 4.0 beta.
I was able to get it [...]
Review of Pro ASP.NET MVC Framework
Filed under: Technology | Tags: ASP.NET, EF, MVC, Unit Testing
A Review of Pro ASP.NET MVC Framework by Steven Sanderson, ISBN 10: 1-4302-1007-9
Update
I started taking notes as I went along, but I’ve not stopped. I really recommend taking this book and working through the exercises. I’m confident you’ll be a better developer even if you’re are not particularly interested in MVC. (Of course, if [...]