public void TestPost() { var server = new TestServer <ProjectClientResponse>("http://localhost:3001", 500); server.Start(); _testScenarioSupport.LoadTestScenario("jacks-test-scenario"); var controller = new AllocationController(new AllocationDataGateway(new DatabaseTemplate(_dataSourceConfig)), new ProjectClient("http://localhost:3001")); var value = controller.Post(new AllocationInfo(-1, 55432, 4765, DateTime.Parse("2014-05-16"), DateTime.Parse("2014-05-26"), "")); var actual = (AllocationInfo)((ObjectResult)value).Value; Assert.True(actual.Id > 0); Assert.Equal(55432L, actual.ProjectId); Assert.Equal(4765L, actual.UserId); Assert.Equal(16, actual.FirstDay.Day); Assert.Equal(26, actual.LastDay.Day); Assert.Equal("allocation info", actual.Info); server.Stop(); }
public void TestPost() { _gateway.Setup(g => g.Create(55432, 4765, DateTime.Parse("2014-05-16"), DateTime.Parse("2014-05-26"))) .Returns(new AllocationRecord(3, 55432, 4765, DateTime.Parse("2014-05-16"), DateTime.Parse("2014-05-26"))); _client.Setup(c => c.Get(55432)).Returns(Task.FromResult(new ProjectInfo(true))); var response = _controller.Post(new AllocationInfo(-1, 55432, 4765, DateTime.Parse("2014-05-16"), DateTime.Parse("2014-05-26"), "")); var body = (AllocationInfo)((ObjectResult)response).Value; Assert.IsType <CreatedResult>(response); Assert.Equal(3, body.Id); Assert.Equal(55432L, body.ProjectId); Assert.Equal(4765L, body.UserId); Assert.Equal(16, body.FirstDay.Day); Assert.Equal(5, body.FirstDay.Month); Assert.Equal(2014, body.FirstDay.Year); Assert.Equal(26, body.LastDay.Day); Assert.Equal(5, body.FirstDay.Month); Assert.Equal(2014, body.FirstDay.Year); Assert.Equal("allocation info", body.Info); }