Tagged Questions
0
votes
0answers
16 views
Can I create a custom TestContext timer for UnitTest/LoadTest in Visual Studio?
A few of my UnitTests have a Sleep that is defined in a loop. I want to profile not only each iteration of the test, but the overall time for all iterations, in order to show any non linear scaling. ...
1
vote
0answers
22 views
How to pass data from a UnitTest to a LoadTest?
During my UnitTest, I am creating data that needs to be referenced in future UnitTests. For example:
[TestMethod]
public void CreateOrder()
{
Order order = new Order();
int orderNumber = ...
0
votes
0answers
15 views
JustMock how to ignore a method call made inside the method under test
I am using JustMock to aid in unit test writing and have come to something that I thought would be fairly simple but can't find the answer to. I can't post any of the code but I'll try to explain ...
0
votes
1answer
60 views
Testing dynamically generated code
I'm working on a project that writes ADO.NET code for a database. Source code located here: GenTools. It reads the stored procedures and tables from a database and outputs C# code. I added unit ...
2
votes
2answers
40 views
Asserting JsonResult Containing Anonymous Type
I was trying to unit test a method in one of my Controllers returning a JsonResult. To my surprise the following code didn't work:
[HttpPost]
public JsonResult Test()
{
return Json(new {Id = ...
1
vote
1answer
43 views
Unit Testing Entity Framework does not return 100% coverage using shims and fakes?
I'm trying to unit test a repository, but what happen is that when I test it I don't get a 100% coverage rather I get a 0% code coverage on that specific method.
I want to test without using third ...
0
votes
0answers
35 views
Setting a property from an interface with a stub
I'm creating a stubed interface and passing it into my test method like shown below. I'm stubbing the interface (StubISeries) that gets passed into the test method. If comparisonSeries.Key is only a ...
0
votes
1answer
88 views
Tool to write an object instance to C# (for unit testing)
Say I have a method that takes a list of objects. The method will normally take 20 objects easy. Each object has 15 or so properties on them.
To unit test this, I need to type out all 20 objects so ...
0
votes
0answers
33 views
Should I shim out methods inside my tested method? [duplicate]
If I'm going to test this method below, would I just need to shim out the two method calls inside my tested method or should my test run these two methods (PreviousQuarterEnd, ResolveDate)and get ...
0
votes
1answer
60 views
Refactoring code in constructor or stub/shim it out?
I have a method I'm testing. The constructor for this method calls to its base class constructor and then in its base class constructor it sets a few members and then executes a method to fetch data ...
0
votes
2answers
20 views
XML Deserialization into C# Objects:Dynamic Classes, Database Refresh
At my organization we use a RESTful architechture for our API. I am creating automated unit tests that can be run after every nightly build. Each API call returns an XML string which i then ...
0
votes
1answer
29 views
NSubstitute cannot setup return value (CouldNotSetReturnException)
I have an interface (called IRepository) that has a method on it like this:
IEnumerable<TEntity> ExecuteStoredProcedure<TEntity>(string functionName,
...
0
votes
1answer
41 views
Having difficulties setting up a mock to unit test WebAPI Post
I'm attempting to set up a unit test with MSTest and Moq for a live system that posts json from a form to a database. The system itself works just fine, but I've been tasked with attempting to build ...
0
votes
2answers
60 views
Is this a proper way of mocking a repository implementation
Having unit-tested my repository interface, I'm now unit testing my repository-implementation. I find that I'm mocking much of the implementation, too much for my comfort. An example follows:
...
0
votes
5answers
69 views
How to write unit tests around private methods
I am trying to unit test a class that has public and private methods and I want to unit test a particular method that has been set as private (protected abstract on the base). I cannot make the method ...