Exemple #1
0
 def test_scan_for_file_open(self):
     """Found .cs file with call to File.Open"""
     Scanner.cs_file_scan(
         ['        using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.None))'],
         'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
 def test_scan_for_file_open(self):
     """Found .cs file with call to File.Open"""
     Scanner.cs_file_scan(
         ['        using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.None))'],
         'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #3
0
 def test_scan_for_filesystem_watcher(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(
         ['        FileSystemWatcher watcher = new FileSystemWatcher();'],
         'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #4
0
 def test_scan_for_extension_but_not_servicebase(self):
     """Found .cs file with class extending FooBar"""
     Scanner.cs_file_scan([
         'using System.ServiceProcess;', 'using System.Text;',
         'using System.Threading.Tasks;', 'namespace WindowsService1', '{',
         '    public partial class Service1 : FooBar', '    {'
     ], 'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(0, len(results))
Exemple #5
0
 def test_scan_for_servicebase_extension(self):
     """Found .cs file with class extending ServiceBase"""
     Scanner.cs_file_scan([
         'using System.ServiceProcess;', 'using System.Text;',
         'using System.Threading.Tasks;', 'namespace WindowsService1', '{',
         '    public partial class Service1 : ServiceBase', '    {'
     ], 'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
     self.assertEqual("20", results[0].refactor_rating)
 def test_scan_for_extension_but_not_servicebase(self):
     """Found .cs file with class extending FooBar"""
     Scanner.cs_file_scan(['using System.ServiceProcess;',
                           'using System.Text;',
                           'using System.Threading.Tasks;',
                           'namespace WindowsService1',
                           '{',
                           '    public partial class Service1 : FooBar',
                           '    {'],
                          'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(0, len(results))
 def test_scan_for_servicebase_extension(self):
     """Found .cs file with class extending ServiceBase"""
     Scanner.cs_file_scan(['using System.ServiceProcess;',
                           'using System.Text;',
                           'using System.Threading.Tasks;',
                           'namespace WindowsService1',
                           '{',
                           '    public partial class Service1 : ServiceBase',
                           '    {'],
                          'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
     self.assertEqual("20", results[0].refactor_rating)
 def test_scan_for_filesystem_watcher(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(['        FileSystemWatcher watcher = new FileSystemWatcher();'], 'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
 def test_scan_for_file_write(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(['File.WriteAllText("foo.bar", "Some Text");'], 'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
 def test_scan_for_ef_use(self):
     """Found .cs file with \"using System.Data.Entity\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
 def test_scan_double_hit_for_ado_net_and_odbc_use(self):
     """Found .cs file with \"using System.Data\'" and \"using System.Data.Odbc\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
 def test_scan_for_ado_net_use(self):
     """Found .cs file with \"using System.Data\'"""
     Scanner.cs_file_scan(['using System.Data;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #13
0
 def test_scan_for_file_write(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(['File.WriteAllText("foo.bar", "Some Text");'], 'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #14
0
 def test_scan_for_ef_use(self):
     """Found .cs file with \"using System.Data.Entity\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
Exemple #15
0
 def test_scan_double_hit_for_ado_net_and_odbc_use(self):
     """Found .cs file with \"using System.Data\'" and \"using System.Data.Odbc\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
Exemple #16
0
 def test_scan_for_ado_net_use(self):
     """Found .cs file with \"using System.Data\'"""
     Scanner.cs_file_scan(['using System.Data;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))