public async Task ShouldReturnNull() { var query = new GetRecentProjectsHandler(); using (var httpTest = new HttpTest()) { httpTest.RespondWith("", 200); var request = new GetRecentProjects("http://tntUrl.xyz", "JEK", "token-1"); var result = await query.Execute(request); result.Should().BeNull("empty string results in null"); httpTest.CallLog.Should().HaveCount(1, "should not fail"); httpTest .ShouldHaveCalled("http://tntUrl.xyz/Ajax/GetPreviousProjects?empID=JEK") // TimePro bug: Basic auth is not base64 decoded on the server and takes the raw token. //.WithBasicAuth("token-1", string.Empty) .Times(1); } }
public async Task ShouldRecentProjects() { var query = new GetRecentProjectsHandler(); using (var httpTest = new HttpTest()) { string response = "[{\"Client\":\"SSWTest\",\"ClientID\":\"SSW\",\"Project\":\"Non-working day (e.g. Leave)\",\"ProjectID\":\"LEAVE\",\"Iteration\":null,\"IterationId\":null,\"Category\":\"Non-working day - Public Holiday\",\"CategoryID\":\"LNWD\",\"DateCreated\":\"\\/Date(1556200800000)\\/\"}]"; httpTest.RespondWith(response, 200); var request = new GetRecentProjects("http://tntUrl.xyz", "JEK", "token-1"); var result = await query.Execute(request); result.Should().HaveCount(1, "raw JSON response has only one response"); httpTest.CallLog.Should().HaveCount(1, "should not fail"); httpTest .ShouldHaveCalled("http://tntUrl.xyz/Ajax/GetPreviousProjects?empID=JEK") // TimePro bug: Basic auth is not base64 decoded on the server and takes the raw token. //.WithBasicAuth("token-1", string.Empty) .Times(1); } }