public void TestPost() { _gateway.Setup(g => g.Create(55432, 4765, DateTime.Parse("2015-05-17"), 8)) .Returns(new TimeEntryRecord(1234, 55432, 4765, DateTime.Parse("2015-05-17"), 8)); _client.Setup(c => c.GetAsync(55432)).Returns(Task.FromResult(new ProjectInfo(true))); var response = _controller.Post(new TimeEntryInfo(-1, 55432, 4765, DateTime.Parse("2015-05-17"), 8, "")); var body = (TimeEntryInfo)((ObjectResult)response).Value; Assert.IsType <CreatedResult>(response); Assert.Equal(1234, body.Id); Assert.Equal(55432, body.ProjectId); Assert.Equal(4765, body.UserId); Assert.Equal(17, body.Date.Day); Assert.Equal(5, body.Date.Month); Assert.Equal(2015, body.Date.Year); Assert.Equal(8, body.Hours); Assert.Equal("entry info", body.Info); }
public void TestPost() { var server = new TestServer <ProjectClientResponse>("http://localhost:3001", 500); server.Start(); _testScenarioSupport.LoadTestScenario("jacks-test-scenario"); var controller = new TimeEntryController(new TimeEntryDataGateway(new DatabaseTemplate(_dataSourceConfig)), new ProjectClient("http://localhost:3001")); var value = controller.Post(new TimeEntryInfo(-1, 55432, 4765, DateTime.Parse("2015-05-17"), 8, "")); var actual = (TimeEntryInfo)((ObjectResult)value).Value; Assert.True(actual.Id > 0); Assert.Equal(55432, actual.ProjectId); Assert.Equal(4765, actual.UserId); Assert.Equal(17, actual.Date.Day); Assert.Equal(8, actual.Hours); Assert.Equal("entry info", actual.Info); server.Stop(); }