public Task Dispatch(DashboardContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var consoleId = ConsoleId.Parse(context.UriMatch.Groups[1].Value);

            var startArg = context.Request.GetQuery("start");

            // try to parse offset at which we should start returning requests
            int start;

            if (string.IsNullOrEmpty(startArg) || !int.TryParse(startArg, out start))
            {
                // if not provided or invalid, fetch records from the very start
                start = 0;
            }

            var buffer = new StringBuilder();

            using (var data = new ConsoleStorage(context.Storage.GetConnection()))
            {
                ConsoleRenderer.RenderLineBuffer(buffer, data, consoleId, start);
            }

            context.Response.ContentType = "text/html";
            return(context.Response.WriteAsync(buffer.ToString()));
        }
Exemple #2
0
        public void DeserializesCorrectly()
        {
            var x = ConsoleId.Parse("00cdb7af151123");

            Assert.Equal("123", x.JobId);
            Assert.Equal(new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc), x.DateValue);
        }
Exemple #3
0
 public void Parse_ThrowsAnException_WhenValueIsTooShort()
 {
     Assert.Throws <ArgumentException>("value", () => ConsoleId.Parse("00cdb7af1"));
 }
Exemple #4
0
 public void Parse_ThrowsAnException_WhenValueIsInvalid()
 {
     Assert.Throws <ArgumentException>("value", () => ConsoleId.Parse("00x00y00z001"));
 }
Exemple #5
0
 public void Parse_ThrowsAnException_WhenValueIsNull()
 {
     Assert.Throws <ArgumentNullException>("value", () => ConsoleId.Parse(null));
 }