Tagged Questions
18
votes
8answers
2k views
What are some indicators that I was over-thinking my solution to this problem?
This question is a cross between career question and a code review. I was uncertain where to ask, but since there is code involved I went with CodeReview.
I’m going through the process of technical ...
5
votes
2answers
137 views
5
votes
1answer
46 views
Verifying the type of an AggregateException's inner exception in a unit test
I've got the following code inside an integration test.
...
5
votes
2answers
87 views
Unit Testing an AppInfo class
I have never written a unit test and I am really new to C#. I am attempting to test a method, am I testing for the right things here?
The Method
...
4
votes
2answers
70 views
Using shims to turn my integration tests into unit tests
I want to understand how to properly unit test a function such as this. The function doesn't return anything, but it does call other functions that themselves have already been unit tested. My ...
5
votes
1answer
83 views
Hard-to-test 3 Tier Architecture
I'm having trouble testing some code. It's laid out in such a way that the business logic relies on the persistence layer.
Some classes require that an object be saved to a database. Some classes ...
3
votes
1answer
85 views
7
votes
3answers
128 views
Unit tests: to cast or not to cast?
Suppose the following example unit test for an ASP.NET MVC controller:
...
4
votes
2answers
70 views
Server side validations and unit testing in MVP
We are following passive controller approach and when user clicks on submit, server side validations are fired. There are many other fields on the screen that needs to be validated.
I would like to ...
7
votes
3answers
157 views
Refactoring method to make it unit testing friendly
I have a completed application which I'm trying to write unit tests for (Yeah I know, talk about bad practices)
I have the following class here
...
0
votes
2answers
95 views
Unit Testing Datalayer written in ADO.net
I have datalayer code as below which is implementing an interface as:
Note: I have hand written this code on Notepad so it may contain some typo errors, which you can gracefully ignore. I am ...
3
votes
1answer
236 views
Unit tests using C#, Moq, AutoFixture, FluentAssertions
Could you give any suggestion on the following unit tests? How to make it more readable, maintainable and trustworthy. If it is not a problem - post some code with the suggestions.
...
1
vote
1answer
100 views
Structuring unit tests
I have settled with this type of structuring of unit tests.
Basic idea is that there is a base test class for the tested class, and a subclass for every tested method. They use the mocks and ...
1
vote
1answer
212 views
Unit testing - test class inheritance vs single test class [closed]
Which unit testing approach and WHY do you prefer?
Inheritance-driven-testing
...
10
votes
1answer
369 views
Writing and reading of a custom binary protocol
I'm currently trying to develop some code that will handle parsing and building of a custom binary protocol. The protocol itself
is still fairly fluid but the basic core features are decided. These ...
3
votes
2answers
103 views
Read Lines From IIS Log
The purpose of this class is to read an IIS log (or multiple ones). One thing to note is that the columns can differ based on settings in IIS.
So a couple of concerns that I have:
Is The ILogReader ...
6
votes
1answer
130 views
How should I structure my Unit tests for minimal Asserts?
I always see comments about how a Unit Test should only be testing one piece of functionality. For the most part, I definitely agree with that assessment. However, I'm working on testing a method ...
2
votes
1answer
211 views
Where to put common method used in controllers that calls service layer?
I have an asp.net mvc5 web application using the repository pattern, and I have several controllers that need to call my _loggingService (queries audit logs) to get the last updated information for ...
7
votes
1answer
119 views
Are these the right type of unit tests to write?
Trying to get an understanding of proper unit testing, I've read up quite a bit and found myself writing tests like the ones that follow. Based on "best practices" etc., how am I doing as far as ...
7
votes
1answer
246 views
Measuring a method executing time
I have been playing around with some improvements to some sort algorithms like Selection Sort and Merge Sort and I ended up needing some sort of measurement to check if my versions were any faster ...
1
vote
1answer
108 views
Testing mapping code
Obviously, you have to test mapping code somehow, even (or especially) if you use AutoMapper. Is there any way to make it less verbose?
...
2
votes
1answer
40 views
7
votes
2answers
144 views
Am I missing any unit tests in this base class for testing equality?
I've created this abstract base class for testing the Equals method.
The basic idea is that derived class implements methods to get:
the primary test instance, ...
8
votes
2answers
115 views
Testing classes
I'm just getting into testing and wanted to see if someone can tell me if I'm writing tests correctly. I'm using C#, NUnit, & Should.
This is the class I'm testing:
...
5
votes
1answer
163 views
Does this FizzBuzz code correctly follow SRP and unit-testing?
This is a code for FizzBuzz. I have also hosted in on my github
FizzChecker Tests
...
4
votes
3answers
159 views
Extracting pattern and simplifying testing
I observe the same pattern in a number of my classes but can't extract/abstract it due the tight coupling inside each particular implementation.
Having the class accepting an optional number of ...
1
vote
1answer
115 views
Is this good practice with unit-testing?
I've created unit test for the "student" CRUD operations that looks like this:
...
6
votes
3answers
330 views
Class that represents an instant in Time
Please review my code and let me know of any additions or modifications that would make this even more useable.
The initial idea was to create a simple Time class that has only one function: To ...
3
votes
2answers
388 views
Test if two IDictionary objects contain the same values
I'm adding a function to my test library to assist in testing if two IDictionary objects contain the same keys/values.
I need the method to be generic and support ...
3
votes
4answers
364 views
Complexity in multiple if-else algorithms
I am learning Algorithms, Part I on coursera.org. I just watched the first lecture then tried to write some code in C#. The class basically stores list of connected numbers. You can add numbers that ...
3
votes
3answers
2k views
Make WCF Service testable
I have WCF Service.
Its work fine and I want to have test coverage for it. Unit tests and acceptance.
The problem is static class using in the code.
How is it possible to avoid it?
If it will ...
2
votes
1answer
177 views
Method names for encapsulated unit testing logic. Which convention is better?
I have some C# unit tests which each basically perform the same steps but supply different arguments to the unit under test.
I wanted to encapsulate the logic inside some "helper methods" but found ...
1
vote
1answer
268 views
Code review on an API wrapper in C# wanted
I'm looking for remarks on pretty much anything. This has been my first project that's meant for use by others and I'd like to have it as clean as possible. I will post the main source code here but ...
4
votes
2answers
238 views
Does my code need refactoring before adding unit tests?
I have this code that works fine, but I would like to create some unit test for this class. Most of the code is in private or ...
4
votes
2answers
2k views
REST Web Api unit test endpoint validity with NUnit and Moq
I am unit testing that the URL that I give to my IRestClient is valid. This client talks to a third party Web API. I am new to unit testing so please bear with me.
...
3
votes
1answer
233 views
Is a unit test which uses LINQ to check multiple values acceptable?
I'm writing unit tests for a library which parses colors from user input (example: the user input “#f00” gives a red color; the user input “60,100%,100%” gives a yellow color, etc.)
One of the ...
2
votes
1answer
219 views
Unit test provider roles
I am unit testing this role provider. I have a few asserts in the code for my test. I am sure there are more test I could preform. Does anyone have any suggestions for more test for this role of the ...
1
vote
2answers
239 views
Am i fake testing or this is how mocking should be implemented?
I'm new to Rhino mock and i would like to know if the test i did is not fake testing as i red a lot about it. are there any improvements need to be done?
...
1
vote
1answer
107 views
unit-testing / mocking a class which contains functionality which depends on itself
Take the below code:
...
5
votes
1answer
503 views
How do I make this code unit-testable?
I have a functionality that imports data into a database, based on an Excel workbook and some meta data (both user-supplied). The functionality implements interface ...
0
votes
3answers
492 views
I need help improving this design for easy unit testing [closed]
I am very new to unit testing, I only read a few chapters from 'Art of Unit Testing' and know how to write basic unit tests. I have a deadline for a project so I plan to read 'Professional Test Driven ...
1
vote
1answer
175 views
Verify collection as a method parameter
How can I verify that ohterClassMock.MethodToTest() was called with contracts?
That it was called with ...
4
votes
2answers
306 views
2
votes
1answer
332 views
Testing database table creation with NUnit
I'm new to using NUnit and have written a test to check for the existence of a database table. I have the below code that should check whether a new table named NewTable has been created in the ...
6
votes
1answer
283 views
Doubts about the quality of an API designed for use with minimal effort
I'll try to provide exactly the amount of context that is necessary to understand the construct.
I built an API (well, a small part of one) that works and is kind of usable, but rather unpretty and ...
4
votes
1answer
314 views
How to make static methods testable?
I am creating an application which will be testable(unit + integration). In this application I have a FileHelper static class,
...
5
votes
3answers
539 views
Maximum Sub-array Problem
I started taking a look at a programming challenge I had read about earlier today on 8thlight. Unfortunately, it seems to have been taken down and all I could remember about it was the problem posed: ...
3
votes
3answers
121 views
Test Driving Interface Design [closed]
I have been doing TDD since I have started my first job out of university (about 5 months ago), most of which is working with legacy code. I started a personal project today and thought I would TDD ...
3
votes
1answer
258 views
Do these unit tests cover my method under test?
I've written an extension method to truncate strings:
...
3
votes
1answer
152 views
Test Driven Development, Mocking & Unit-testing
I have the below code which is still under development - but I'm trying to get myself to find the ideal way to move forward.
...