Contents tagged with Tips

  • dynamic, Why not?

    In these days, people begin to expertise some new features in .NET 4.0. And I am same to them as well. One of features I like and write to this post is dynamic keyword. It is not new, at least in PHP, Python, Ruby... But in .NET world, I think it is new and ship to .NET 4.0 as a default. And some of projects are ported to .NET based on DLR as IronPython, IronRuby. We can use dynamic keyword in anywhere in our project. How do you think about it? So dynamite, isn’t it? :D. Some of people are didn’t like it, some else are love it. How about you? With me, I only try to utilize a new feature in .NET 4.0 for make my work is easier.

  • Generating Report for NUnit

     All source codes for this post can be found at my github.

    Time ago, I received a request that people ask me how they can generate reports of the results of testing using NUnit? In fact, I may never do this. In the little world of my programming, I only care about the test results, red-green-refactoring, and that was it. When I got that question quite a bit unexpected, I knew that I could use NCover to generate reports, but reports of NCover too simple, it did not give us more details on the number of test cases, test methods, ...

  • Unit testing for a project that some classes inside it is marked with internal keyword

    Have you ever written a component that used for a other solution? This is meaning you write a component (for example, a third party, a extensions,...). So we usually use the "internal" keyword inside all classes in your component. Is it right?  And as you know if you use the "internal" keyword, you will not access from outside. Now I assume that you have a testing project out side the component project. How can you access to the internal classes inside your component project? If you try access to this component project, you will get one error "Cannot access internal class <ClassName> here"
    This post only a tips and tricks, so you can use it to access to the component that mark with the "internal" keyword. It is just simple is you must tell to the component project to assign enough permission to a assembly that want to access to your component.
    In order to make this, you are only need open the AssemblyInfo.cs file, and append one line to the end of this file. And this line is:
    [assembly: InternalsVisibleTo("<Namespace of the assembly that you want to access to this assembly>")]
    For example, I have the component project with namespace is Cik.Domain and the Unit Testing project is Cik.Domain.Testing. So I must open the AssemblyInfo.cs file inside the Cik.Domain project and add one line at the end of this file as: [assembly: InternalsVisibleToCik.Domain.Testing")]
    Now compile all projects, and all things will work well. You shall have enough visible to use some classes inside your component and do unit testing for it. I hope this tips and tricks will be useful for you.