import os
from queue import Queue
from shutil import which
from unittest.case import skipIf

from bears.c_languages.CSharpLintBear import CSharpLintBear
from tests.LocalBearTestHelper import LocalBearTestHelper
from coalib.settings.Section import Section


@skipIf(which('mcs') is None, 'mono mcs is not installed')
class CSharpLintBearTest(LocalBearTestHelper):

    def setUp(self):
        self.section = Section("test section")
        self.uut = CSharpLintBear(self.section, Queue())
        self.test_file1 = os.path.join(os.path.dirname(__file__),
                                       "test_files",
                                       "csharplint_test1.cs")
        self.test_file2 = os.path.join(os.path.dirname(__file__),
                                       "test_files",
                                       "csharplint_test2.cs")

    def test_run(self):
        # Test a file with no issues
        self.check_validity(self.uut, [], self.test_file1)

        # Test a file with issues
        self.check_validity(self.uut, [], self.test_file2, valid=False)
