Contents tagged with Unit test

  • One more summary of Moq library

    Examples of Mock usages

    Mock - is a simple and lightweight isolation framework, which is built on the basis of anonymous methods and expression trees. To create them it uses code generation, thus allowing to mock interfaces, virtual methods (and even protected methods) and does not allow to mock non-virtual and static methods.

    NOTE

    At market exists only two frameworks that allow to mock anything. These are TypeMockIsolator and Microsoft Fakes, available in Visual Studio 2012 and higher. These frameworks, unlike Mock ( which uses code generation) use CLR Profiling API, allowing to mock any method even for static, virtual and private methods. IMHO they are good for testing legacy code … more

  • What makes a good Unit test

    Hello everybody,

    today some notices of what is considered to be a good unit test.

    1. Tests should be independent and isolated.  

    For example if you have functions a, b, c tested, then sequence of test shouldn't affect the result. 

    2. Each test should test single behaviour or logical staff. 

    If to speak about phone example, calling and sending sms shouldn't be in one functoin

    3. Clear purpose understood.

    4. Don't test the compiler ( like writing/reading to db )

    5. Reliable and repetable ( give the same result ).

    6. Quality the same as other parts of solution.

    7. Valuable for developers more

  • What are Asserts in NUnit

    Hello everybody,

    just short notice of NUnit function Assert.That

    [Test]

    public void CheckAddition()

    {

    Assert.That(CalculatorClass.Minus (5, 2), Is.EqualTo(3));

    }

    public void CheckAddition()

    {

    //old styel Assert.AreEqual(3, CalculatorClass.Minus (5, 2));

    }

    more