public void GetTimeReturnsOkStatusCode() { var service = new TheService(); var req = new HttpRequestMessage(); var resp = new HttpResponseMessage(); service.GetTime(req,resp); Assert.AreEqual(HttpStatusCode.OK,resp.StatusCode); }
public void GetTimeReturnsCurrentTime() { var service = new TheService(); var req = new HttpRequestMessage(); var resp = new HttpResponseMessage(); service.GetTime(req, resp); var s = resp.Content.ReadAsString(); DateTime dt; Assert.True(DateTime.TryParse(s, out dt)); var ts = DateTime.Now.Subtract(dt); Assert.True(ts.Duration().TotalSeconds < 1.0); }