Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I a have a solution containing 25 projects comprised of both C# and managed C++.
I need to test one of the C# project calls but this project is of type "Window application" (Not DLL).
Even though it is a windows application, my requirement is to call only few internal functional calls (Not related to windows form).
I need to create a separate C# test project to call this functionality. Is it possible to do it like this?
Can anyone suggest a way or examples? And one more thing, I cannot modify the existing code.
Is it possible to do it like this?
Yes. Referencing the project you wish to test in a test project is typically how you unit test your code.
Can any one suggest a way or examples?
Create a unit test project, reference the project that contains the code you wish to test, write tests to test the code you wish to test. If you need to refactor the code to make it testable, do so, or see point below.
And one more thing, i don't have any freedom to modify the existing
source code.
In this case, you are going to have to wrap the code in some cleaner interfaces to allow you to test the code.
The book, Working Effectively with Legacy Code by Michael Feathers has some excellent advice on how to get legacy code under test.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
The project I am working on will have to be migrated from C# to F# based on what brings food on the table tomorrow - in other words, the two languages have to live side by side in this project for years to come.
The problem I am faced with repeatedly is how I should organize projects in the solution to meet this need.
I translate pieces from C# to F# all the time, because it frequently shortens the development time and increases the quality. But I end up with C# code that wants to use F# code, and F# code that want to use C# code, in the same layer, or at boundaries between layers or modules. I find myself putting code in the wrong projects just to avoid creating yet another project in some layer.
The situation is not bad now, but I worry that I will paint myself into a corner at some point, unless I can come up with a pattern or a structure, or simply understand the problem better.
Is there some modification to a normal F# architecture - a pattern, a substructure or a superstructure - that is well suited to such a mixed solution?
Are there patterns that are known to be especially helpful in solving this particular challenge?
Use an interface to communicate between the two languages.
Typically when porting, f# is the lower-level dll and C# can call f# as usual.
Now for f# to call c# define an interface in the f# dll (e.g. IClibApi) that is implemented in c# (e.g. ConcreteClibApi extends IClibApi). Create an instance of ConcreteClibApi and pass it to f#. Now f# can call c# thru IClibApi.
Later you can start porting ConcreteClibApi :)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
If you're developing application using the code contracts, you may know, that this concept was introduced in Eiffel programming language.
I have become very confused after trying this concept in my C# application using System.Diagnostics.Contracts.
The main question for me is the next:
Are unit-tests really needed, if you have code contracts?
One of the major differences, that unit-test frameworks usually don't provide, is the possibility to call private methods (except MS fakes library with its shims). It's done, because of supporting composition & the idea, that private methods are covered by public method calls.
As for the code contracts, I can declare Contract.Requires, Contract.Ensures for private methods.
So, why do I need unit-testing, when I have code-contracts, which behavior is very similar.
Thanks
You surely need Unit testing.
With code contracts, you can only have your static contract verification.
There's much more you can do when running your code.
For example, say you are testing a class that depends on IConnectionProvider. What happens when your GetConnection throws? Code contracts won't help you with that.
Ideally you'd be testing the public methods of your class with different inputs, and verifying that it behaves as expected. This will help you find bugs, and in the long run, design better code.
I would say no. By using code contracts you are defining what your code is supposed to do and checking that it is doing it. The unit test does the same thing for the most part so I believe it is redundant to the point that it is not cost effective to write both.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm starting on the second version of a large Solution/Project that I created and was wondering about the best way to go about it. I'll be changing allot of the core code, classes and projects of the solution and that makes want to make this into a separate solution and separate repository.
I've never really started on a version 2 before, so if anybody could give me advice on the best way to go about it I would truly appreciate it.
For the record I am coding in C# and using VS2012.
Thank You
Create a Branch in the repository called Version2 or something (maybe a better code name) and do all the new dev work in that. That way you still have the original Trunk if you need to go back to it. Maybe also create a Tag with the current project that will never change so you basically take a snapshot of it before making any substantial changes.
I usually keep everything in one solution and just evolve the solution. There are several benefits to this:
You refactor your tests along with the project (hope you do have some!)
Keep a tracked version of all the changes in your source control
It's easier to make sure your project is still stable after the refactoring by running test suits or running the executables in debug mode
It is safer to refactor little bits and peaces, than a global re-write, there is a risk you will go a little bit to far with refactoring
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Members at work have come across a C# project posted on Google code that provides a nice solution to a problem they have in a current project. What are the implications/restrictions on using those ideas (or in some cases code snippets) to use in their own project?
I must express that my colleagues are not trying to rip off somebody else’s code and call it their own, but like the way that the Google project is structured and tackles a specific problem. I believe they are looking to refactor their code to a similar architecture and use one or two code snippets from the source code.
The code itself does not come with any licence or terms just a solution.
I have never come across this before but don’t want to get involved doing this work if it I could be liable to comebacks. I have suggested that some form of recognition be added to the code pages that use any snippets.
Thanks
If there are no license or terms you cannot use any code snippets from the original work. Ask the creator of the original work for permission to use it in the way you like.
https://stackoverflow.com/questions/1190628/what-license-is-public-code-under-if-no-license-is-specified
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am still visiting school and will finish my exams next year. Since two years I am working as (the only :-( ) in-house dev for a company providing financial services to Laboratories and doctors. After spending the first year fixing their existing Application and realizing, communicating and agreeing that it won't meet future requirements i rewrote it from scratch. This is my first LOB application.
I needed a "IEnumerable.ToDataTable()" method to do simplify certain things in the Application. I realized that existing solutions wouldn't meet my performance and flexibility requirements, so i came up with a solution based on Dynamically injected IL code myself.
I thought that this might be a good way to contribute to the community, thats why i asked my employer if i may take some of those code and release it under LGPL. They agreed and that's where my first project is:
ModelShredder
Since this is my first OSS project and i am relatively unexperienced with running an OSS project on my own I am asking you for some "best-pratices" and what i can improve on it.
First read this book:
You can download it free of charge here: http://producingoss.com/ There are also some nice screencasts there that may be some use too.
It covers everything you need to know about looking for, contributing to, starting and maintaining an open source project,
It all depends on if you're going to have a team help you or not. It'll be simpler to start doing it yourself if you have the time if for no other reason than you can work out how you want to proceed without worrying about politics.
For a start, any code used as a framework or a library typically needs to be developed to a much higher standard than what you might write for an internal application. This means you need:
Sufficient user and developer docuemtnation;
Unit tests with decent coverage;
A license;
Tagged versions in source control; and
Released binaries and source code with checksums.
Additionally you'll need a method of:
Communicating your project status (release notes, goals, etc); and
A means to allow people to raise and track issues.
Google Code (as just one example) can do pretty much all of this for you.
I would also suggest you register the domain name for your project (typically projectname.org for open source). If the one you want is taken already, you may want to change the project name, particularly as there might be cause for confusion.
The google code pages look pretty good to me. You might want to think about adding a support group on Google Groups.