C# - Stubbing .NET Page.Form For Unit Tests?

Feb 22, 2011

Fo unit testing ASP.NET controls I need a stubbed Page.

I can create an ASP.NET Page object in my unit tests by subclassing System.Web.UI.Page.However, I cannot find a way to set Page.Form. Adding a form with attribute (runat,server)does not work. Overloading the form in my Subclass does not give the required functionality.

Context:I try to unit test some homemade ASP.NET controls. These control require Page and Page.Form not to be null.

View 3 Replies


Similar Messages:

C# - Is Possible To Run Some Unit Tests As Smoke Tests

Oct 21, 2010

In my project we use UnitTests (MsTest). We run them manually and in the build script.But for some environments where we deploy manually.We are in the need of having some smoke tests. At the moment I made this smoke tests "manually" (Login, create an user, create a licence, create a product, etc). I know I can run unit tests from command line or from visual studio but...Do you know if is possible to run these mstests (or probably a small subset) from an .aspx page and show the results?EDITED: wondering if mstests or something is able to run the tests and have something visual to show in an .aspx page similar to a list of tests passed and tests failed...I am thinking on running only a small subset of tests (5-6)

View 1 Replies

Writing Useful Unit Tests?

Jul 7, 2010

I have a simple page with a Grid that I'm binding a collection of objects to. I also have some simple functionality on the grid to edit and save rows. I would like to write unit tests for this page, but it's not really making sense to me.For example:

Private Sub LoadGrid()
'Populate Collection
grid.datasource = MyCollection
grid.databind()
end sub

I guess a Sub really doesn't need a unit test, but what if this were a function that returned true when the grid had been loaded. How do you write a unit test for this? What other test should be done on a simple web page like this?

View 2 Replies

MVC :: Unit Tests For Action Which Uses RedirectToAction?

Oct 13, 2010

I have Action method in a controller which uses RedirectToAction(actionName, routeValues[])I want to write the unit test for action method to check the following - 1. action name2. ViewData after executing the RedirectToAction.

View 1 Replies

C# - How To Fake HttpContext For Unit Tests

Aug 15, 2010

I need to fake HttpContext.Current.Application table to access it from my unit tests.I need to store my data somewhere. I thought that I can just pass instance of NameValueCollectionBase but as I descover this base type has no indexer so it's too complicated to use. So what about faking this part of HttpContext? Is it possible? How can I make it? Will be NUnit.

View 2 Replies

How To Apply Unit Tests In .NET Webforms

Mar 31, 2010

I'm developing a website in asp.net webforms with 3 layers; UI, BLL and DAL.The website is already developed, but i like have more control about the unit tests of each form Pass specific values at specific inputs for i see, if application survives or not.

I already study about NUnit but in webforms in UI layer how can apply these tests?What i wnat is get some way to test UI (validations) without have to access to the BLL as i was an user.

I'm trying to add the Unit tests to my app but i not sure how to do it!

View 2 Replies

MVC :: Enabling .NET MVC2 Unit Tests In VWD?

Mar 16, 2010

As stated in http://forums.asp.net/t/1535916.aspx the unit tests are missing from the ASP.NET MVC 2 RTM source code, but are available on CodePlex at

http://aspnet.codeplex.com/releases/view/41742).

After installing ASP.NET MVC2 RTM on Visual Web Developer 2008 Express, apparently unit tests are not enabled for VWD - when I create a new MVC2 project I don't get the "Create Unit Test Project" dialog box where I can say"Yes, create a unit test project".(I thought I was presented with that dialog box in earlier versions of either MVC2 RC or MVC1, but maybe not...)

Given the source code on codeplex, is it possible to use that to enable unit tests for MVC2 for VWD Express? If so, are the steps one have to take detailed somewhere?

View 5 Replies

How To Make HttpContext Available To Be Used By My Unit Tests

Aug 13, 2010

I want to write a unit test which tests the function of a class called UploadedFile. The problem I face is this class' static constructor uses HttpContext.Current property and because I am running my unit test from a class library I do not have an HttpContext at the testing time.

Look at my static constructor:

static UploadedFile()
{
if (HttpContext.Current == null)[code]....

What should I do in my testing environment so that HttpContext.Current won't be null and I can successfully set this:

HttpServerUtility server = HttpContext.Current.Server;

View 2 Replies

Continuous Integration For .Net And Javascript With Unit Tests?

May 4, 2010

I need a Continuous integration tool that will support both .Net Unit tests and Javascript unit tests and perform the builds.It looks like my main options are CruiseControl.NET using JUnit and NUnit or Team City and JS Test Driver.

Are there any other options and which ones have you used or had good or bad experiences with.

View 1 Replies

Visual Studio :: 'File Not Found' In Unit Tests?

Oct 19, 2010

I have a unit test that reads from an .xml file and it works fine on my local machine.However, in TFS when I create a new build it gives the following exception:

Failed GetArticleByIdTestOptimal Test method Test.ArticleSystemTest.GetArticleByIdTestOptimal threw exception: System.Xml.XmlException: ImportFromFile filePath=[.Articles1to5.xml]. ---> System.IO.FileNotFoundException: Could not find file 'c:uildareaTestResults fservice
2010-10-19 11_52_19_Any CPU_ReleaseOutArticles1to5.xml'..

Is there some reason why a unit test could pass locally but not in TFS? I've verified that the file is on the build server.

View 1 Replies

JQuery :: Integrate Unit Tests With Visual Studio?

Mar 17, 2011

I recently came accross the following article on Stephen Walther's website

[URL]

Basically, it provides some excellent guidance on how to integrate your Javascript tests into Visual Studio. I followed the steps in the article and successfully managed to test Javascript methods using Visual Studio tests.

I am unable however to unit test JQuery methods (I get errors such as "window" undefined). I was wondering if anyone has successfully managed to test jQuery methods on the server using the above link?

View 2 Replies

Unit Testing Error - The Unit Test Adapter Failed To Connect To The Data Source Or To Read The Data

May 6, 2010

I'm using VSTS 2K8 and I've set up a Unit Test Project. In it, I have a test class with a method that does a simple assertion. I'm using an Excel 2007 spreadsheet as my data source.

My test method looks like this:

[Code]....


As indicated in the method decoration attributes, my Excel spreadsheet is on my local C:/ Drive. In it, the sheet where all of my data is located is named "Sheet1".I've copied the Excel spreadsheet into my project and I've set its Build Action = "Content" and I've set its Copy to Output Directory = "Copy if Newer".

When trying to run this simple unit test, I receive the following error:

The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library. Error details: ERROR [42S02] [Microsoft][ODBC Excel Driver] The Microsoft Office Access database engine could not find the object 'Sheet1'. Make sure the object exists and that you spell its name and the path name correctly.

I've verified that the sheet name is spelled correctly (i.e. Sheet1) and I've verified that my data sources are set correctly.Web searches haven't turned up much at all.
[Code]....

View 5 Replies

Run A Unit Testing On A Web Page (events...etc) In Visual Studio 2008?

Aug 4, 2010

is there any tutorial about how to run a unit testing on a web page (events...etc) in visual studio 2008? is it even possible? i can find anything to start with

View 1 Replies

Tests Set Of Url's And Checks If Get Redirected To Another

Apr 23, 2010

I made a small program which tests a set of url's and checks if they get redirected to another set of urls. Now this program has been working fine till I got a few urls which are of the form [URL] Now the problem occurs when I have a url with "//" not the http://, whenever I use any url with "//" it produces the error The server committed a protocol violation. Section=ResponseStatusLine. If I test the same in the browser it loads the page, but I cannot check the same throught the application. If I remove the "/" then it should work, but then the site wont load.

View 2 Replies

Web Tests Without VS 2010 Ultimate?

Dec 13, 2010

At my previous job we had VS 2008 Team Edition which included the ability to do web tests and load testing right in VS. Currently the company I'm at has VS 2010 Professional but we are thinking of upgrading to Premium, but this still leaves us without the built in Web Testing/Load Testing ability directly in VS.

I'm going to talk to my IT Director and see if they might be willing to go for ultimate, but I need to know first if any off-the-shelf products can fill this hole as the cost is almost double for the Ultimate edition of VS 2010.I really like the testing abilities in 2008 that I worked with, but really just need some of the similar functionality. The ability to record a test and then group a series of tests together, see the HTPP values and results, possibly the ability to do data driven tests and DEFINITELY the need for load testing.

View 2 Replies

MVC :: Use The Structure Map Configuration For The Tests?

Sep 12, 2010

On a MVC 3 Preview Web Application I am using the following:

1 - Structure Map for IOC

2 - Fluent Validation for Validation

3 - AutoMapper for mapping.

Everything is working fine.Now I created a Test Project. How can I use the same Structure Map configuration for the tests?

View 5 Replies

Web Forms :: How To Post Data From One Form To Other Form Using Cross-Page Technique

Jan 14, 2011

I have Master Page and ascx user controls in my application.

how would I use the Cross-Page technique using the @ PreviousPageType directive.

useful links or samples to achieve this.

I am trying to use the Page class that exposes a property named PreviousPage from my User Control.

View 3 Replies

Web Forms :: IFrame Form Data Capture Upon Parent Page Form Submit Action

Jun 8, 2010

I have a web form called default.aspx which has a form with user information. In addition to this, I have an iFrame on the same page that displays a page Secondary-Form.aspx that has a few additional dynamic data fields. I need to do two things.

1. I need to pass the parent form data in real time to the iFrame page to refresh its content and modify it's fields accordingly. Example: If the user submits their Vehicle Choice as Car on parent form, the form item in iFrame will display a radio button that says Honda, and if the user submits their Vehicle Choice as MotorCycle in the parent page, the iFrame will display Harley Davidson as the radio button choice

2. The submit button is on the parent page. I want both pieces of this information (from the parent page, as well as iFrame selection) to be passed to a server side ASPX page to process this information.the default.aspx and Secondary-Form.aspx files are located on different domains.

View 2 Replies

Visual Studio :: Cannot Run More Than 2 Database Integration Tests

Nov 24, 2010

I have written some database integration tests in the format of MS unit test. If I run each test, it runs fine. If I run 2 integration tests, it runs fine. However, if I runs 3 or more test at the same time, one test will show "In Progress", and other shows "Pending", basically, it does not make any progress at all, stays there forever. I turned on SQL Server Profiler, it does not show the test hit the database at all.

Here are some examples of my method:

[Code]....

Here are examples above method integration tests:

[Code]....

View 1 Replies

.net - Is It Possible To Run Tests Using The NUnit Framework In A Hosted Website

Sep 8, 2010

But I have other tests that are essentially deployment tests (you can't test how the production deployment went using a unit test on a build server) and I'd like to use the nUnit framework to run these.But, the production server doesn't have the nUnit command line executer. I'm only allowed to run aspx pages and reference .dll's in bin.What do I need to do to run tests (yeah, yeah, they're not really unit tests--relax) using nUnit in a webpage? Is there a straight forward way to do this, or does this essentially require porting the nUnit winforms test runner to ASP.NET?

View 1 Replies

Web Forms :: Create Form In Asp Which Reloads Another Form Without Refreshing Page?

Jan 26, 2011

i need to create a dynamic form that switches the contents of the page without reloading or refreshing the page.

View 10 Replies

Web Forms :: Changing Form Id (form) In Child Page?

Mar 24, 2011

Previously form id in child pages was aspnetform,suddenly now the id has changed to form1, now the problem is there are lots of script used with reference to id aspnetform and they are giving error. So i want to change or override the form1 name to aspnetform to make it work again

View 4 Replies

How To Integration Testing On Application Without Necessarily Running All The Tests Via The Browser

Jun 4, 2010

ASP.Net MVC - How should i do integration testing on an ASP.net MVC application without necessarily running all the tests via the browser?

View 1 Replies

Want To Try And Test An Action Method On Controller That Itself Tests If IsAjaxRequest() Is True?

May 28, 2010

I'm just starting to use the TestHelpers in MvcContrib. I want to try and test an action method on my controller that itself tests if IsAjaxRequest() is true. I've used the same code that is shown in the TestHelper samples to set up the TestControllerBuilder

_controller = new StarsController();
_builder = new TestControllerBuilder();
_builder.InitializeController(_controller);

So that _controller has all the faked/mocked HttpContext inside it, which is really great. But what do I do now to force IsAjaxRequest() on the internally faked Request object to return true?

View 2 Replies

Architecture :: Reading Values From Config Files In NUnit Tests?

Aug 18, 2010

One of my NUnit tests has to read in some values from config files. In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in. Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work. Are there any special steps involved when reading from config files in an nunit test ?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved