コード例 #1
0
 public MockContract(string id,
                     string description,
                     ServiceRequest request,
                     ServiceResponse defaultResponse,
                     IContractEvent[] contractEvents,
                     IContractPackage package)
 {
     this.Id          = id;
     this.Description = description;
     this.Request     = request;
     this.Response    = defaultResponse; //默认的响应
     _contractEvents  = contractEvents;
     this.Package     = package;
 }
コード例 #2
0
        public static MockContract Create(DTObject dto, IContractPackage package)
        {
            var id          = dto.GetValue <string>("id", string.Empty);
            var description = dto.GetValue <string>("description", string.Empty);

            //request
            var requestDTO = dto.GetObject("request", DTObject.Empty);
            var request    = ServiceRequest.Create(requestDTO);

            //response
            var responseDTO = dto.GetObject("response", DTObject.Empty);
            var response    = ServiceResponse.Create(responseDTO);

            var events = dto.GetList("events", false) ?? DTObjects.Empty;
            List <IContractEvent> ces = new List <IContractEvent>(events.Count);

            foreach (var e in events)
            {
                ces.Add(ContractEventFactory.CreateCE(e));
            }

            return(new MockContract(id, description, request, response, ces.ToArray(), package));
        }