Unit testing a Winforms event driven architecture
What approach should I take (if it's even possible) to unit test a standard event driven Winforms app where display and logic are mixed together. ...
What approach should I take (if it's even possible) to unit test a standard event driven Winforms app where display and logic are mixed together. ...
I need to run some code only if I'm running from within the TeamCity test launcher. What's the easiest way to detect this? ...
public Category GetByName(string name) { Category category = Session.CreateCriteria(typeof (Category)) .Add(Expression.Eq("Name", name)) .UniqueResult<Category>(); return category; } Or is it so clear that it doesn't need testing? ...
I'm testing some code that uses StructureMap for Inversion of Control and problems have come up when I use different concrete classes for the same interface. For example: [Test] public void Test1() { ObjectFactory.Inject<IFoo>(new TestFoo()); ... } [Test] public void Test2() { ObjectFactory.Initialize( x => x.ForR...
I have a ArticleController that displays a list of articles according to a category. public ActionResult List(string categoryname) { MyStronglyTypedViewData vd = new MyStronglyTypedViewData(); DBFactory factory = new DBFactory(); categoryDao = factory.GetCategoryDao(); articleDao = factory.GetArticleDao(); ...
My object under test has two dependency objects of the same type. Sometimes when a test has a failed expectation, it's not clear which dependency object set that expectation. Is there some way to give the dependency objects names that will appear in the error messages so that I can tell them apart? Here's an example: MockReposi...
My class has like 30-40 properties, and I really want to unit test. But I have to create a moq instance (many of them, with different combinations etc). Is there an easy way? This is real work! My class can't be refactored, "trust me" (hehe, no really it can't, they are just properties of the object that are very tightly coupled). ...
I have a unit test that is failing because a System.ArgumentException is being thrown, even though I am expecting it and it's deliberate behaviour - what have I missed? [Test] [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Seconds from midnight cannot be more than 86400 in 010100712386401000000012")] public void TestPa...
So I have an order manager class that looks like: public class OrderManager { private IDBFactory _dbFactory; private Order _order; public OrderManager(IDBFactory dbFactory) { _dbFactory = dbFactory; } public void Calculate() { _order.SubTotal _order.ShippingTotal ...
Normally I would do this: public class DBFactory { public UserDAO GetUserDao() { return new UserDao(); } } Where UserDao being the concrete implementation of IUserDao. So now my code will be littered with: DBFactory factory = new DBFactory(); IUserDao userDao = factory.GetUserDao(); Use...
is there a way to test routes via nunit? ...
when unit testing a asp.net controller, don't you have to somehow mock the httpcontextbase? All my controllers inherit from a custom controller class that I wrote (it just adds some common properties to the original controller class). So its like: public class MyController : Controller { protected override void OnActionExecuting(Sy...
I have a unit test for an Http handler. In it I create a HttpResponse object and pass it to one of my Http handler's methods. One of my tests attempts to verify that the response headers have been set correctly: Assert.AreEqual( "gzip", response.Headers["Content-Encoding"]); However, the Headers property throws a PlatformNotSupported...
Hello, I just cannot for the life of me get my nant build file to terminate upon a test failure and return (thus preventing the packaging and artifact step from running) This is the unit part of the nant file: <target name="unittest" depends="build"> <nunit2 verbose="true" haltonfailure="false" failonerror="true" failonfailureatend=...
I have the following so far which I am trying to unit test: private Mock<IDBFactory> _mockDbFactory; private IArticleManager _articleManager; [Setup] public Setup() { _mockDbFactory = new Mock<IDBFactory>(); _articleManager = new ArticleManager(_mockDbFactory); } [Test] public void load_article_by_title() { string t...
I want to use Moq, but I am using Nhibernate and I didn't create interfaces for all my Model classes (POCO classes). Do I have to create an interface for each class for me to be able to moq my POCO classes? ...
Not sure how I can fix this, trying to do a unit test on the method "GetByTitle" Here are my definitions: public class ArticleDAO : GenericNHibernateDAO(IArticle, int>, IArticleDAO { public IArticle GetByTitle(string title) { IQuery query = Session.CreateQuery("...") return qu...
I wanted to start a discussion about the details that you cover in your unit tests. Do you test major functionalities, that consist of several methods doing one task at once with one test? or maybe you even test automatic properties? Because, for example, I see little value in writing a test that would test only this: public Email ...
I'm using NUnit 2.5 and NAnt 0.85 to compile a .NET 3.5 library. Because NAnt 0.85 doesn't support .NET 3.5 out of the box, I've added an entry for the 3.5 framework to NAnt.exe.config. 'MyLibrary' builds, but when I hit the "test" target to execute the NUnit tests, none of them seem to run. [nunit2] Tests run: 0, Failures: 0, Not run:...
I am a college student that makes his programs here and there in c#, mostly scientific simulations. Is there any use in learning NUnit? I keep hearing people talking about it but I don't fully grasp what it is in the first place. Is it something that every programmer should use, or something that is more suited for big projects with lots...