The real question is "Is a withdrawal allowed if it results in a negative balance?" and that isn't necessarily a function of that method - for example, my current account has a "permitted overdraft" permanently attached so by balance can genuinely and acceptably go negative, up to a preset limit.
So having a Withdraw method that automatically refuses a transaction if it would result in a negative balance may be against the business logic. In addition, accounts often have "pending transactions" which may not be reflected in the balance but which could change the "approve / reject" decision.
Think about how you are doing this: you should probably divide the responsibilities up into three sections - Presentation (user interface), Business logic, and Data handling - and a withdrawal request would come from the Presentation to the Business for approval, and on then be committed to Data storage by the Business logic if approved, or rejected to the Presentation if not.
Certainly, I don't think an exception would be right - normal processing shouldn't use exceptions for flow control.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
BTW, using decimal instead of double is a good idea because math performed on doubles is not as accurate as math performed on decimals.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
I 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
am cyrrently working on a file monitoring system in c# that records all events in log format, with a command to dump logs as .txt files.
my question is, is the a code i could use to dump these log files into a file, save them at a specific time in the day.
say while its monitoring, it automatically saves the logs in a file at 23:59 everyday.
while monitoring a particular folder.
given there is a path in which to save.
We need to bring a Word document into focus and then paste text into the document at the current cursor location. We know the name of the Word document. Unfortunately Word only has one instance and one main window, which means that I cannot simply locate the window, bring it into focusand paste the data. Is there a way to do this from C#?
Thanks for the response. Our requirements are that the user must be able to configure our system such that data from a reader is pasted into a user chosen application. Because this is generic, the way we do it is to bring the app into focus and then paste the data. For images we use the clipboard.
This is not intended to run on someone's work PC, rather it is an automated system, and giving an app focus is desirable as the operator can see the read data.
We wish to post into the cursor position in the target document.
I already do that. Unfortunately Word only has one main window. I've tried to enumerate the child windows but that does not work, it only locates the topmost. If you run up two documents, then look in Task Manager, you'll see what I mean: one process and one window.
This is one of those questions that can end up in semi-religious wars with people wanting to burn the heretics who don't do things "their way". If you are part of a team and the standard is to just test public implementations, then you just test public implementations. If that team insists on unit testing everything, then test the private methods as well.
I have to admit that I prefer tests that only test the public methods. Basically, if you have a private method that you can't get to somehow via your public methods then either that code is "dead code", or you have a serious problem with your architecture and are relying on reflection in the main codebase to get at this code and run it. Thing is, if you follow SOLID principals, no single part of your codebase should be that large that you can't adequately cover the private methods via the public methods/properties.
Don't you think that testing only the public methods creates a problem?
When a test of a public method fails, it is not clear where it fails. Is it in the public method called directly by the test, or in a private method called by the public method?
Last Visit: 31-Dec-99 19:00 Last Update: 7-Dec-23 17:07