vendredi 24 juillet 2015

How to cover following with tests

after installing NCrunch I have found out that a lot of lines are not covered by tests. For example following code.

using System;

namespace Ei.Exceptions
{
  public class FactoryException: Exception
  {
    public object Factory { get; private set; }

    public FactoryException(string message) : base(message)
    {
    }

    public FactoryException(object factory, string message) : base(message) {
        this.Factory = factory;
    }
  }
}

I tried to write a test, but it does not cover it:

[TestFixture]
class FactoryExceptionTest
{
    [Test]
    void FactoryException_Created_ReturnsInstance()
    {
        var exception = new FactoryException("Test");
        Assert.AreEqual(exception.Message, "Test");

        var exception2 = new FactoryException("Factory", "Test");
        Assert.AreEqual(exception.Message, "Test");
        Assert.AreEqual(exception.Factory, "Factory");
    }
}

Any ideas please?

Aucun commentaire:

Enregistrer un commentaire