Exemplo n.º 1
0
        public void ContractAuditor_AcsRequired_Test()
        {
            var whiteList = new List <string>
            {
                "System.Collection",
                "System.Linq"
            };
            var blackList = new List <string>
            {
                "System.Random",
                "System.DateTime"
            };

            _auditor = new ContractAuditor(whiteList, blackList);

            var requireAcs = new RequiredAcsDto();

            requireAcs.AcsList = new List <string> {
                "acs1"
            };
            Should.Throw <InvalidCodeException>(() => _auditor.Audit(_badContractCode, requireAcs, true));

            Should.NotThrow(() => _auditor.Audit(_systemContractCode, requireAcs, true));

            requireAcs.AcsList.Add("acs8");
            Should.NotThrow(() => _auditor.Audit(_systemContractCode, requireAcs, true));

            requireAcs.RequireAll = true;
            Should.Throw <InvalidCodeException>(() => _auditor.Audit(_systemContractCode, requireAcs, true));
        }
Exemplo n.º 2
0
 public ContractAuditorFixture()
 {
     _auditor     = new ContractAuditor(null, null);
     _requiredAcs = new RequiredAcsDto
     {
         AcsList = new [] { "acs1", "acs8" }.ToList(),
         RequireAll = false
     };
 }
Exemplo n.º 3
0
        public void ContractAuditor_Basic_Test()
        {
            var whiteList = new List <string>
            {
                "System.Collection",
                "System.Linq"
            };
            var blackList = new List <string>
            {
                "System.Random",
                "System.DateTime"
            };

            _auditor = new ContractAuditor(blackList, whiteList);

            Should.Throw <InvalidCodeException>(() => _auditor.Audit(_badContractCode, _requiredAcs, true));
        }
Exemplo n.º 4
0
 public void Dispose()
 {
     _auditor = null;
 }
 public ContractAuditorTests()
 {
     // Use fixture to instantiate auditor only once
     _auditor = GetRequiredService <ContractAuditor>();
     _patcher = GetRequiredService <IContractPatcher>();
 }