public void Setup()
 {
     _dataGetter     = Substitute.For <IDataGetter>();
     _postRepository = Substitute.For <IPostRepository>();
     _dataConvertor  = Substitute.For <IDataConvertor>();
     _dataDisplayer  = Substitute.For <IDataDisplayer>();
     _dataGetter.GetData().Returns(_data);
     _dataConvertor.ConvertMarkdownToHtml(_data).Returns(_data);
 }
Exemplo n.º 2
0
        public static async Task <MessageData> GetMessageDataAsync(IDataGetter getter, int msgType, long handle)
        {
            try
            {
                //Console.Write("Enter a message to Send: ");
                var task = await Task <MessageData> .Factory.StartNew(() => getter.GetData(handle));

                //getter.SetData(null);
                return(task);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public (bool created, string errorMessage) Generate(int id)
        {
            var data = _dataGetter.GetData(id);

            (bool valid, string errorMessage)result = _dataValidator.ValidateData(data);

            if (!result.valid)
            {
                return(result);
            }

            ReportOutput reportOutput = _dataFormatter.FormatData(data);

            return(_reportDistributor.DistributeReport(reportOutput));
        }
Exemplo n.º 4
0
 public Exporter Data(IDataGetter data)
 {
     _data = data.GetData(HttpContext.Current);
     return(this);
 }
Exemplo n.º 5
0
        //private static Exporter Instance()//旧方法,反射controller会导致方便调用时session为空
        //{
        //    var export = new Exporter();
        //    var context = HttpContext.Current;

        //    //if (context.Request.Form["titles"] != null)
        //    //    export.Title(JsonConvert.DeserializeObject<List<List<StoreColumn>>>(context.Request.Form["titles"]));//原本的title是从前端传过来,现改为统一用_data里的columns

        //    if (context.Request.Form["dataGetter"] != null)
        //    {
        //        export.Data(context.Request.Form["dataGetter"]);
        //        var columns = (export._data as PagingResult).columns as StoreColumnCollection;//这里可以扩展为多表头
        //        export.Title(new List<List<StoreColumn>> { columns });
        //    }

        //    if (context.Request.Form["fileType"] != null)
        //        export.Export(context.Request.Form["fileType"]);

        //    if (context.Request.Form["compressType"] != null)
        //        export.Compress(context.Request.Form["compressType"]);

        //    return export;
        //}


        public Exporter Data(IDataGetter data)
        {
            //_data = data.GetData(HttpContext.Current);
            _data = data.GetData(_controller, HttpContext.Current);
            return(this);
        }
Exemplo n.º 6
0
 public IBlogPostData GetData()
 {
     return(_dataGetter.GetData());
 }