0

I want to cover my dispose method in unit test (using nunit framework), written inside repository

public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }
    protected virtual void Dispose(bool disposing)
    {
        if (_disposed)
            return;

        if (disposing)
        {
            _bpRioCostCentreContext.Dispose();
        }
        _disposed = true;
    }
    ~CostCentreRepository()
    {
        Dispose(false);
    }
Eagle
  • 25
  • 8
  • Wrap the class in a using and assert the expected behavior after, Or just manually call the dispose member and assert expected behavior – Nkosi Aug 05 '19 at 14:38
  • Have a look at this https://stackoverflow.com/questions/3259456/should-dispose-methods-be-unit-tested – Nkosi Aug 05 '19 at 14:40

0 Answers0