Exemple #1
0
        void HandleRenderSpec(HttpContext context, SpecWriterAccessor accessor)
        {
            var dk     = accessor.DataKeeper;
            var called = dk.GetCalledMethods().ToList();

            if (called.Count == 0)
            {
                context.Response.Write(JsonConvert.SerializeObject(new {
                    code    = "// Currently no code. Why not call some methods?",
                    hasCode = false
                }));
                return;
            }

            var type = called.First().Target;

            var spec = accessor.WithWriter(cw => {
                var ctx = new SpecContextImpl(
                    OrDefault(context, "Subject", "subject"),
                    OrDefault(context, "BoostrapClassName", "Bootstrap"),
                    OrDefault(context, "Namespace", "YourNamespace.Here"),
                    OrDefault(context, "Title", "No special title").Replace(" ", "_"),
                    called,
                    type,
                    s => new SimpleNameEnumerator(s),
                    typeof(DataContractSerializer));
                return(cw.WriteContext(ctx));
            });

            context.Response.Write(JsonConvert.SerializeObject(new {
                code    = spec,
                hasCode = true
            }));
        }
    void HandleRenderSpec(HttpContext context, SpecWriterAccessor accessor) {
      var dk = accessor.DataKeeper;
      var called = dk.GetCalledMethods().ToList();
      
      if (called.Count == 0) {
        context.Response.Write(JsonConvert.SerializeObject(new {
          code    = "// Currently no code. Why not call some methods?",
          hasCode = false
        }));
        return;
      }

      var type = called.First().Target;

      var spec = accessor.WithWriter(cw => {
        var ctx = new SpecContextImpl(
          OrDefault(context, "Subject", "subject"),
          OrDefault(context, "BoostrapClassName", "Bootstrap"),
          OrDefault(context, "Namespace", "YourNamespace.Here"),
          OrDefault(context, "Title", "No special title").Replace(" ", "_"),
          called,
          type,
          s => new SimpleNameEnumerator(s),
          typeof(DataContractSerializer));
        return cw.WriteContext(ctx);
      });

      context.Response.Write(JsonConvert.SerializeObject(new {
        code = spec,
        hasCode = true
      }));
    }
Exemple #3
0
        bool MatchesTarget(HttpContext context, SpecWriterAccessor accessor)
        {
            var target = context.Request["target"] ?? "";

            switch (target)
            {
            case "":
                return(false);

            case "status-submit":
                HandleStatus(context, accessor);
                return(true);

            case "start-recording":
                HandleStartRecording(context, accessor);
                return(true);

            case "stop-recording":
                HandleStopRecording(context, accessor);
                return(true);

            case "clear-recording":
                HandleClearRecording(context, accessor);
                return(true);

            case "render-spec":
                HandleRenderSpec(context, accessor);
                return(true);
            }
            return(false);
        }
Exemple #4
0
 void HandleStartRecording(HttpContext context, SpecWriterAccessor accessor)
 {
     accessor.Control.StartTrace();
     context.Response.Write(
         JsonConvert.SerializeObject(new {
         running = true,
         status  = Status(true),
         count   = accessor.DataKeeper.CurrentCount()
     }));
 }
Exemple #5
0
        void HandleStatus(HttpContext context, SpecWriterAccessor accessor)
        {
            var running = accessor.Control.IsStarted();

            context.Response.Write(
                JsonConvert.SerializeObject(new {
                running,
                status = Status(running),
                count  = accessor.DataKeeper.CurrentCount()
            }));
        }
Exemple #6
0
        void HandleClearRecording(HttpContext context, SpecWriterAccessor accessor)
        {
            accessor.DataKeeper.Clear();
            var isStarted = accessor.Control.IsStarted();

            context.Response.Write(
                JsonConvert.SerializeObject(new {
                running = isStarted,
                status  = string.Format("Cleared recording. {0}", Status(isStarted)),
                count   = accessor.DataKeeper.CurrentCount()
            }));
        }
 bool MatchesTarget(HttpContext context, SpecWriterAccessor accessor) {
   var target = context.Request["target"] ?? "";
   switch (target) {
     case "":
       return false;
     case "status-submit":
       HandleStatus(context, accessor);
       return true;
     case "start-recording":
       HandleStartRecording(context, accessor);
       return true;
     case "stop-recording":
       HandleStopRecording(context, accessor);
       return true;
     case "clear-recording":
       HandleClearRecording(context, accessor);
       return true;
     case "render-spec":
       HandleRenderSpec(context, accessor);
       return true;
   }
   return false;
 }
 void HandleClearRecording(HttpContext context, SpecWriterAccessor accessor) {
   accessor.DataKeeper.Clear();
   var isStarted = accessor.Control.IsStarted();
   context.Response.Write(
     JsonConvert.SerializeObject(new {
       running = isStarted,
       status  = string.Format("Cleared recording. {0}", Status(isStarted)),
       count   = accessor.DataKeeper.CurrentCount()
     }));
 }
 void HandleStatus(HttpContext context, SpecWriterAccessor accessor) {
   var running = accessor.Control.IsStarted();
   context.Response.Write(
     JsonConvert.SerializeObject(new {
       running,
       status = Status(running),
       count  = accessor.DataKeeper.CurrentCount()
     }));
 }
 void HandleStartRecording(HttpContext context, SpecWriterAccessor accessor) {
   accessor.Control.StartTrace();
   context.Response.Write(
     JsonConvert.SerializeObject(new {
       running = true,
       status = Status(true),
       count = accessor.DataKeeper.CurrentCount()
     }));
 }