When creating a unit test for a class that uses the HttpContext.Current.Cache class, I get an error when using NUnit. The functionality is basic - check if an item is in the cache, and if not, create it and put it in:
if (HttpContext.Current.Cache["Some_Key"] == null) {
myObject = new Object();
HttpContext.Current.Cache.Insert(...
I already have a test setup up for this function but I would like to know if it's the best way to go about it. I have a method like this:
public static string RunTableInfoCommand(IMapinfoWrapper wrapper,
TableInfoEnum infoToReturn)
{
//pass the int value of infoToReturn to underlying COM objec...
I'm having a bit of trouble doing some unit-testing using moq.
If I have a function like this:
public string GetName(IMapinfoWrapper wrapper)
{
return wrapper.Evaluate("My com command");
///"My comm command" is the same all the time.
}
Then I have a test that checks the return value of the GetName function:
[Test]
public void ...
I have a Django app that requires a settings attribute in the form of:
RELATED_MODELS = ('appname1.modelname1.attribute1',
'appname1.modelname2.attribute2',
'appname2.modelname3.attribute3', ...)
Then hooks their post_save signal to update some other fixed model depending on the attributeN defined....
This question is self explanatory if you know how to use JMockit: How do I mock a method that has generics on it? I want to mock this method: public T save(T entity) but it always throws an exception like this:
mockit.RealMethodNotFoundForMockException: Corresponding real methods not found for the following mocks:
Object save(Object)
...
I'm using Mockito to write a unit test in Java, and I'd like to verify that a certain method is the last one called on an object.
I'm doing something like this in the code under test:
row.setSomething(value);
row.setSomethingElse(anotherValue);
row.editABunchMoreStuff();
row.saveToDatabase();
In my mock, I don't care about the order ...
Hi,
I am wondering should I write unit test for everything. There are some classes is very difficult to write unit test. For example, I am writing some program for handling audio. The class for capturing audio from microphone, and class for play audio to speaker, how can I write unit test for those classes? I can't get output and input ...
As I understand it, a mock object created with RhinoMocks enter the recording state directly when it is created, and then you call Replay() to enter the replay state. I would like to manually decide when the mock object starts recording, or be able to pause the recording. Would that be possible in RhinoMocks?
Thanks
/Erik
...
Is it possible to mock a static method using Rhino.Mocks ?
if Rhino does not support this.. Is there a pattern or something which would let me accomplish the same ?
...
I've been using the MvcMockHelpers class found at Hanselman's blog for passing in a mocked HttpContext. We extended it somewhat to add some authentication data we needed and for the most part this has been great.
The issue we are having is that the context we are giving to the controller has a null value in the HttpContext.Response.Outp...
How can I mock one method with RhinoMocks in VB.Net? The reference I found is in C#:
Expect.Call(delegate{list.Add(0);}).IgnoreArguments()
.Do((Action<int>)delegate(int item) {
if (item < 0) throw new ArgumentOutOfRangeException();
});
SharpDevelop converts this to:
Expect.Call(Function() Do
list.Add(0)
...
I have an action class that expects a FormFile from a DynaActionForm. Typically in JMock, I'll just add request params to the struts mock, which will in turn populate the DynaActionForm.
Obviously, the set request param is for strings only. So I'm unsure how to get or set the mock to use a multi-part request such that I can add the Fo...
My apologies, I read this post:
http://stackoverflow.com/questions/316897/tdd-and-ado-net-entity-framework
But I don't think it covers what I'm looking for and other similar questions seem unanswered. So, forgive me if this has already been answered.
I have an application that I'm writing. I've created some Entity classes. I want to m...
I would like to have a JUnit (or other) system where the enterprise beans can be tested in a mock environment so that all resources/beans and so on are injected locally. The enterprise beans should not have to accomplish this. All kinds of injection should be supported.
I would like to have a maven plugin for this so that the tests can...
Hi!
In a upcoming project I'm going to write an application in C# which partly has to communicate with a HTTP server. I'm very fond of writing my code TDD-style, and I would just love it if I could mock all of the HTTP requests in my tests.
Does any one here know about an easly mockable HTTP client framework?
Ps. I usually use Moq for...
I'm connecting to a simple, if idiosyncractic, external service.
I believe that my unit tests should not depend on the availability or implementation of that external service, so I intend to mock it out.
I need the mock to accept and return realistic messages and responses - otherwise my tests won't represent real states of affairs. Fo...
I am writing a test that depends on the results of an extension method but I don't want a future failure of that extension method to ever break this test. Mocking that result seemed the obvious choice but Moq doesn't seem to offer a way to override a static method (a requirement for an extension method). There is a similar idea with Moq....
I'm testing my rails helper methods like this:
require File.dirname(__FILE__) + '/../../test_helper'
require 'action_view/test_case'
require 'action_view/helpers'
class ListingsHelperTest < ActionView::TestCase
def setup
@controller = ListingsController.new
@request = ActionController::TestRequest.new
@response = Action...
Please advise on the easiest learning path, as well as simple mocking library to start with.
...
We have a URL object in one of our Java classes that we want to mock, but it's a final class so we cannot. We do not want to go a level above, and mock the InputStream because that will still leave us with untested code (we have draconian test coverage standards).
I've tried jMockIt's reflective powers but we work on Macs and there are ...