App.config in Test Projects

Well, if you need a App.config file shared across several projects, I would simply “Add as Link” the original App.config file in each project. Let’s say you have ProjectA with the original App.config. Then you have ProjectATest1 and ProjectATest2. In each of the TestX project: right click on the solution name in Visual Studio select … Read more

TDD and JPEG compression

Joel’s question was something like this. Suppose you wanted to set a bit somewhere that caused a low resolution image to be displayed rather than a high resolution image. How would you use TDD to get that to work? Would you write a test that scraped the screen to show that the image was in … Read more

Dependency injection in TypeScript

I have developed an IoC container called InversifyJS with advanced dependency injection features like contextual bindings. You need to follow 3 basic steps to use it: 1. Add annotations The annotation API is based on Angular 2.0: import { injectable, inject } from “inversify”; @injectable() class Katana implements IKatana { public hit() { return “cut!”; … Read more

How to exclude Projects with names ending in “.Test” from my code coverage analysis in VS2012 Unit Tests

There is a connection with the period issue as it was mentioned here. If you change the exclude section to this <ModulePath>.*tests.dll</ModulePath> <ModulePath>.*Tests.dll</ModulePath> or this <ModulePath>.*\.tests\..*</ModulePath> <ModulePath>.*\.Tests\..*</ModulePath> it’ll work

Testing asynchronous function with mocha

You have to specify the callback done as the argument to the function which is provided to mocha – in this case the it() function. Like so: describe(‘api’, function() { it(‘should load a user’, function(done) { // added “done” as parameter assert.doesNotThrow(function() { doRequest(options, function(res) { assert.equal(res, ‘{Object … }’); // will not fail assert.doesNotThrow … Read more

Setup method in Moq, ambiguous call

Try the generic version of Returns: var matchSetupRepository = new Mock<IMatchSetupRepository>(); matchSetupRepository .Setup(ms => ms.GetAll()) .Returns<IEnumerable<MatchSetup>>(null); or: var matchSetupRepository = new Mock<IMatchSetupRepository>(); matchSetupRepository .Setup(ms => ms.GetAll()) .Returns((IEnumerable<MatchSetup>)null); Instead. Because you’re passing the function null (and there are two overloads of Returns), the compiler does not know which overload you mean unless you cast the argument … Read more

Rails fixtures — how do you set foreign keys?

You should use named fixtures, which automatically generate an id number for you where you don’t provide one. These id numbers are essentially integer hashes of whatever string you use. Don’t add the “_id” if you’re referencing the named version: # recipes.yml chicken_soup: cookbook: my_recipes # cookbooks.yml my_recipes: title: My Test Cookbook