Using Moq to Mock a Func constructor parameter and Verify it was called twice

I don’t think it is necessary to use a mock for the Func. You can simply create an ordinary Func yourself that returns a mock of IFooBarProxy: int numberOfCalls = 0; Func<IFooBarProxy> func = () => { ++numberOfCalls; return new Mock<IFooBarProxy>(); }; var sut = new FooBar(func); sut.Process(); Assert.Equal(2, numberOfCalls);

Best way to take screenshots of tests in Selenium 2?

To do screenshots in Selenium 2 you need to do the following driver = new FireFoxDriver(); // Should work in other Browser Drivers driver.Navigate().GoToUrl(“http://www.theautomatedtester.co.uk”); Screenshot ss = ((ITakesScreenshot) driver).GetScreenshot(); //Use it as you want now string screenshot = ss.AsBase64EncodedString; byte[] screenshotAsByteArray = ss.AsByteArray; ss.SaveAsFile(“filename”, ImageFormat.Png); //use any of the built in image formating ss.ToString();//same as … Read more

The opposite of assert_select?

Take a look at the docs here: http://apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select From the docs: assert_select is an assertion that selects elements and makes one or more equality tests. and from the equality tests sections: The equality test may be one of the following: true – Assertion is true if at least one element selected. false – Assertion is … Read more

Catching exceptions from Guzzle

Depending on your project, disabling exceptions for guzzle might be necessary. Sometimes coding rules disallow exceptions for flow control. You can disable exceptions for Guzzle 3 like this: $client = new \Guzzle\Http\Client($httpBase, array( ‘request.options’ => array( ‘exceptions’ => false, ) )); This does not disable curl exceptions for something like timeouts, but now you can … Read more

Difference between acceptance test and functional test?

In my world, we use the terms as follows: functional testing: This is a verification activity; did we build a correctly working product? Does the software meet the business requirements? For this type of testing we have test cases that cover all the possible scenarios we can think of, even if that scenario is unlikely … Read more

What is the difference between unit tests and functional tests?

Unit tests tell a developer that the code is doing things right; functional tests tell a developer that the code is doing the right things. You can read more at Unit Testing versus Functional Testing A well explained real-life analogy of unit testing and functional testing can be described as follows, Many times the development … Read more