It depends on your risk-estimation. If you think the private methods are fault-free. => No UnitTest If you think the private methods can have bugs, but the consequences are tolerable. => No UnitTest If you think the private methods can have bugs, but the consequences are NOT tolerable. => Unittest them. Example 1: If you are contributing "private" code to your team and you think some bugs are tolerable => No Unittest. Example 2: If your "private" code controls the cooling-system of a nuclear power-plant and you think the risk of bugs is tolerable => No UnitTest If you consider your question in this way (as I do in practice), the answer is quite easy. If you still don't know what to do, ask your boss, if he accepts bugs in "private" code or not.
Frygreen
Posts
-
Should I unit test private methods? -
Nunit3: Debug of Testcases. => No breakpoints hit with console-runnerIt does not help. I was already aware of this :( But thank you very much ! ! ! I searched a lot of links, but all I found is referencing quite old versions of Nunit. I use NUnit.Console-3.7.0. All of my tests are executed "perfectly". The only problem is: Breakpoints are not hit
-
Design-Question: Using ReturnValue or Throwing ExceptionBased on all of your feedback and some additional search I have the following solution for me I will return a Transaction-Object
struct TransactionResult {
double amountReturned;
EnumTransactionResult eReturn;
}Some more info: - I have no complicated scenarios as "Pending Transactions" - Of course: I can overdraw the account upto an allowed value, which can be less than zero - This fully fulfills my use-case Thank you for your input. My question is fully answered
-
Design-Question: Using ReturnValue or Throwing ExceptionI have an Account class, which has a function
double WithDraw(double amountToWithdraw) {
...some code here....
}If the balance of this account is <= 0, then what should I do? ==> throw an exception (which one?) ==> return 0.0 with some additional information? (in which way?) I guess: a) throwing an exception could be wrong, because this scenario is not "exceptional", but standard b) returning some additional information requires to return a object with additional attributes or a reference to an object in the parameterlist. Seems to be crazy too.
-
Nunit3: Debug of Testcases. => No breakpoints hit with console-runneryes, the complete dll-bunch is in one single directory. Together with all pdb's
-
Nunit3: Debug of Testcases. => No breakpoints hit with console-runnerI cannot debug (set breakpoints,...) my UnitTests with NUnit3. What works already My Test-Dll's contain all the tests. They are executed and the result is displayed correctly in the output-window when I run them with the console-runner. So, the test-setup itself seems to be correct. What I want: I want to DEBUG my tests when they are executed with the console-runner and stop at breakpoints. What I did so far: => I create a Dll, which contains the testcases/-fixtures. => I have set this Dll-Project as startup-project => At Properties | Debug of the Dll-Project I select the console-runner as"Start external Program" and I add the command-line arguments ( my dll ) => I set breakpoints in my test-code => I start a debug-session: The tests are executed, but not breakpoints are hit It seems, I misunderstand some concept completely
-
asp.net mvc with desktop ui. HowTo?It's me again. I created my first asp.net-site, following this link Building your first MVC 6 application — ASP.NET MVC documentation[^] I have no problem with the "Model-View-Controller"-Pattern, but: a) I am intimidated by this enormous bunch of tools I had to setup before the project was built successfully b) there is an endless number of files generated which tells me nothing Finally: I am sure, nobody in this world is able to understand what's going on here :-)
-
asp.net mvc with desktop ui. HowTo?I am developing desktop-apps. Now I want to go to a web-based approach with asp.net mvc as a framework. I want to skip the Silverlight-approach and instead want to do it html5-JScript-based (with asp.net mvc). I do not have such kind of modern high-end-multimedia screens. Instead, my requirement is to keep the "usual desktop like UI" as menues, win-forms, .... for showing things like datagrids Can you give me some hint how to make the first steps? Thank you in advance
-
How to get Data from web-server to Silverlight-AppFirst: I am an absolute beginner :-) and I want to learn basics. I have created a Silverlight-App and embedded it in a asp.net MVC page on a WebServer (it works fine). Now I want to do my first steps: Loading an Xml-File from the WebServer into my SilverlightApp, which running in the Browser of a ClientComputer Question: How can I send some "basic kind of request" from the SilverlightApp to the Server to send the xml-file? I surfed a lot in the internet, but I am confused about all of these very complex data-access-possibilities.
-
How to implement a service "beside" my web-siteI try to explain: This means, that other programs retrive data from different sources, they preprocess it, and store it, e.g. in a database. The web-server now reads the data from this database and presents it to the user
-
How to implement a service "beside" my web-siteA beginner's problem: I have a asp.net web-site running on a webserver. Additionally, on this server I want to have running some other programs, which generate data as input for this web-site. E.g. such a program/service observes a requirements-database, and generates a report. This report should be the input for the web-site and can then be accessed by users. How can such a szenario be realized?
-
Absolutely lost with starting asp.net mvcI rarely found such a good training site in my life Thank you very much
-
Absolutely lost with starting asp.net mvcThanks a lot for these very helpfull information. Much better than what I found so far I have another one :-) The views I found in many examples contain more or less a lot of html-code. Is is possible to use a kind of "graphical html-designer" to create this native code automatically?
-
Absolutely lost with starting asp.net mvcI want to start with asp.net mvc and I am absolutely lost with terms and concepts. I work through a lot of microsoft trainings. But all samples mix up endless different concepts and terms. Can somebody give me a link to some kind of "bottom-up-tutorial"?
-
Continuous Integration: CruiseControl vs Jenkins vs ???We just started to setup our CI world with Jenkins. Now we have to create tons of extensions in Java which is really cumbersome as our complete focus is on C#.
-
Continuous Integration: CruiseControl vs Jenkins vs ???For .net developers, there is this quite old CruiseControl available for as CI-Server. Jenkins is somehow now state of the art for Java Development. Question: Is the anything as Jenkins available, based on .net? I talk about freeware?
-
How to find interfaces in code programmaticallyDear reader, at startup of my program I want to find all instances/classes, which support an special interface. Example: I have class A, which supports interface "void someFct()" I have class B, which supports interface "void someFct()" At startup of my program, I want to call both functions/interfaces without registering them before. I hope you can understand, what I want? Have a nice day ############### update ######################## I try to describe my problem better My app reads a lot of data-sources and then it executes a list of ReportInstances, where each report creates excel-reports/sheets. This takes roughly 10 minutes. Each individual report checks/validates its input/config/... before it executes its own business-logic. In practice it happens, that in worst case the last report detects an error at its validation and the program stops. This is very annoying. Simplyfied code here:
void CreateReport( params here ) {
CreateReport_1(par);
CreateReport_2(par);
.......
}My idea is: Do validation, before starting the single reports
Solution 1: Register all validation-delegates and execute them before starting the reports
This kind of code is
void CreateReport( some params ) {
// GetValidationDelegate() are static functions
myValidationList.Add( Reporter_1.GetValidationDelegate());
myValidationList.Add( Reporter_2.GetValidationDelegate());foreach (validationDelegate in myValidationList) { execute validationDelegate; }
// Validation is done, start now with reports
CreateReport_1(par);
CreateReport_2(par);
.....
}This is easy, but it has the disadvantage, that each time I add a new reporter I have to change my "registration-code". It is some kind of maintenance problem.
Solution 2: Do it "more automatic", this is what I am looking for
The kind of code I am looking for is
void CreateReport( some params ) {
myValidationList = GetAllAvailableValidationDelegates()
foreach (validationDelegate in myValidationList) {
execute validationDelegate;
}
// Validation is done, start now with reports
CreateReport_1(par);
.....
}I am looking for the code of "GetAllAvailableValidationDelegates()", which "parses" automatically all available classes/instances in my program and looks for such delegates
-
Sql Server Express: Testing sql-commands...for the moment.... thank you for your kind replies
-
Sql Server Express: Testing sql-commandsDear reader, I am totally new in database-programming. I have available all the standard-books but still, I feel lost in that area. I am working with Sql Server Express-Edition One of my basic questions is: How can I test SQL-commands from any kind of tool. It seems, that the express-edition does not have all the tools installed. Another question is: Is it ok to start programming with "basic Ado.Net" and not focussing on EF or Linq? Best regards
-
How to model endless-loop with states in UML-state-diagramDear readers, I have a endless loop, which has internal state. How can this be modelled with UML-State-Diagram?
static int state = 0;
void mySstateTest(void)
{
for(;;) {
DoSomeImportantAction();if ( 0 == state ) { if ( 1 == ReadSomeData() ) { state = 1; } } if ( 1 == state) { if ( 0 == ReadSomeData() ) { state = 0; } } }
}
Is there a better place for asking this question Thank you