Is there a nice way to make it so that functions are public when I am testing with NUnit, but private otherwise?
Not having to generate a lot of extraneous code would also be nice.
------------------------Edit------------------------
It seems the solutions fall under 3 types:
Might there be a way to do this programmatically? i.e. just create a new temporary app that makes all protected/private/internal
functions public
, plug that into NUnit, run the tests there, and then go back to using the private functions for the release version?
C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
One of the most significant features of C language is its support for dynamic memory management (DMA). It means that you can utilize and manage the size of the data structure in C during runtime. C also provides several predefined functions to work with memory allocation.
C has the features of both assembly level languages i.e low-level languages and higher level languages. So that's why C is generally called as a middle-level Language. The user uses C language for writing an operating system and generates menu driven customer billing system.
Instead of private
<->public
you can make them internal
<->public
using InternalsVisibleTo
.
InternalsVisibleTo
is an assembly attribute that you can use in the assembly you want to make visible to your unit test assembly. You will have to sign your unit test assembly, because the InternalsVisibleTo
attribute relies on the public key of the calling assembly.
You might not need to if you have good coverage on your public methods which call the private methods but that seems to be another debate into it self.
This is a good link about TDD and different ways to do it: How to Test Private and Protected methods in .NET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With