예제 #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 CSharpContractAuditor(whiteList, blackList);

            var requireAcs = new RequiredAcs();

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

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

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

            requireAcs.RequireAll = true;
            Should.Throw <CSharpInvalidCodeException>(() => _auditor.Audit(_systemContractCode, requireAcs));
        }
예제 #2
0
 public ContractAuditorFixture()
 {
     _auditor     = new CSharpContractAuditor(null, null);
     _requiredAcs = new RequiredAcs
     {
         AcsList = new[] { "acs1", "acs8" }.ToList(),
         RequireAll = false
     };
 }
 public ContractAuditor(CSharpContractAuditor contractAuditor)
 {
     _auditor     = contractAuditor;
     _requiredAcs = new RequiredAcs
     {
         AcsList = new[] { "acs1", "acs8" }.ToList(),
         RequireAll = false
     };
 }
예제 #4
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 CSharpContractAuditor(blackList, whiteList);

            Should.Throw <InvalidCodeException>(() => _auditor.Audit(_badContractCode, _requiredAcs));
        }
예제 #5
0
 public void Dispose()
 {
     _auditor = null;
 }