The following test:
[TestClass]
public class MyTestClass
{
private TestContext _testContext;
protected TestContext TestContext
{
get { return _testContext; }
set { _testContext = value; }
}
[TestMethod]
[HostType("ASP.NET")]
[UrlToTest("http://localhost/MyPage.aspx")]
public void TestMyPa...
I am unit testing an ICustomerRepository interface used for retrieving objects of type Customer.
As a unit test what value am I gaining by testing the ICustomerRepository in this manner?
Under what conditions would the below test fail?
For tests of this nature is it advisable to do tests that I know should fail? i.e. look for id 4 when...
I created OCUnit test in concordance with "iPhone Development Guide". Here is the class I want to test:
// myClass.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface myClass : NSObject {
UIImage *image;
}
@property (readonly) UIImage *image;
- (id)initWithIndex:(NSUInteger)aIndex;
@end
// myClass.m
#import "my...
I'd like to create various network errors during testing. I'm using the Berkely sockets API directly in C++ on Linux. I'm running a mock server in another thread from within Boost.Test which listens on localhost.
For instance, I'd like to create a timeout during connect. So far I've tried not calling accept in my mock server and sett...
I've got a C# form, with various controls on it. The form controls an ongoing process, and there are many, many aspects that need to be right for the program to run correctly.
Each part can be unit tested (for instance, loading some coefficients, drawing some diagnostics) but I often run into problems that are best described with an exa...
Hi there,
We're trying to migrate a .Net 3.5 solution into .Net 4.0, but are experiencing complications with the testing frameworks that can operate using an assembly that is built using version 4.0 of the .Net Framework.
Previously, we used NUnit 2.4.3.0 and NCover 1.5.8.0 within our NAnt scripts, but NUnit 2.4.3.0 doesn't like .Net 4...
Hi,
What I want to achieve is after loading my object from the database, to generate a code that will give me a block which initializes my object based on its current values so that I can use this code-block in my unit tests again and again without loading it from Db anymore.
Is there any tool around to achieve such a goal for VS?
tha...
Hi,
I'm currently testing the controller in my mvc app and I'm creating a fake repository for testing. However I seem to be writing more code and spending more time for the fakes than I do on the actual repositories. Is this right?
The code I have is as follows:
Controller
public partial class SomeController : Controller
{
IRepos...
Specifically, I've got a method picks n items from a list in such a way that a% of them meet one criterion, and b% meet a second, and so on. A simplified example would be to pick 5 items where 50% have a given property with the value 'true', and 50% 'false'; 50% of the time the method would return 2 true/3 false, and the other 50%, 3 tru...
I am trying to mock the Ajax.IsRequest() method of ASP.Net MVC. I found out how to do it in order for it to return true:
Expect.Call(_myController.Request.Headers["X-Requested-With"]).Return("XMLHttpRequest").Repeat.Any();
This works and returns true. Now I need to test the other branch of the code. How can I mock it to return false? ...
Hi,
I'm having difficulty testing controllers. Original my controller for testing looked something like this:
SomethingController CreateSomethingController()
{
var somethingData = FakeSomethingData.CreateFakeData();
var fakeRepository = FakeRepository.Create();
var controller = new SomethingController(fakeRepository);
...
I'm trying to test my REST service with WebCache attribute
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public partial class MyContract : IMyContract
{
[OperationContract()]
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "items/{cod...
I would like to provide some custom Assert methods in my MSTest Unit Testing framework. I have my own static class "CustomAssert", and methods like the one below:
public static void DatesAreEqualToDay(DateTime expectedValue, DateTime actualValue)
{
if (!(
expectedValue.Year == actualValue.Year &&
expectedValue.Month =...
I am trying to grasp the entire TDD methodology and as such, I don’t really know how to present this as a nice concise question so here is the long drawn out version.
I seem to be experiencing a gap between the bowling (Martin), money (Feathers), and other similar game/simple examples and a fully functioning Enterprise app.
I am trying ...
Say I have the class
class myClass(object):
pname = ""
def __getName(self):
return pname
def __setName(self, newname):
if not isalpha(newname):
raise ValueError("Error")
elif
self.pname = newname
name = property(fget=__getName,fset=__setName)
Seeing as these methods are private, and I...
As shown in a domain-manager article, I am interested in creating an integration test harness that creates a server and many clients, where all of them are running within a single process. But once I achieve this goal I will be very tempted to execute such integration & system tests from within a unit testing framework (NUnit or VS Team...
Okay, often I'll have a method that returns a Set of some sort. The problem with unit testing such a method is that there is no guarantee an iteration over the set will always return the items in the same order.
Does anyone have any preferred method of validating a Set?
Peter
...
I'm having problems running my Rails unit tests via autotest using Test::Unit 2.0.6. Running tests via rake test:units works perfectly, but when I run the tests from autotest, I get this:
/Code/projectdir/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Test::Unit::TestResult:...
Im trying to unit test a class in some Java code that I've inherited.
Problem is that it derives from a class that is part of the company's application framwwork. Upon construction, the base class does all sorts of 'clever' stuff, initialising connections to all kinds of services that are needed at runtime.
But for unit testing purpose...
I have a windows phone 7 silverlight app that I'm trying to unit test. My tests fail with the following error:
System.DivideByZeroException : Attempted to divide by zero.
On the following line:
Deployment.Current.Dispatcher.BeginInvoke(() => RaisePropertyChanged("Lat"));
I assume this is because there is no ui thread. Do I need to ...