コード例 #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));
        }
コード例 #2
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));
        }
コード例 #3
0
 public void Audit(byte[] code)
 {
     _auditor.Audit(code, _requiredAcs, false);
 }
コード例 #4
0
        public void CheckSystemContracts_AllShouldPass(Type contractType, bool acsAllRequired = false, params string[] acsList)
        {
            var requiredAcs = new RequiredAcs
            {
                RequireAll = acsAllRequired,
                AcsList    = new List <string>(acsList)
            };

            _auditor.Audit(ReadPatchedContractCode(contractType), true);
            Should.Throw <CSharpCodeCheckException>(() =>
                                                    _auditor.Audit(ReadPatchedContractCode(contractType), requiredAcs, false));
        }