public async Task When_InitiateDysacOnlySessionWithNoErrors_ReturnOK() { var userSession = new DfcUserSession(); userSession.PartitionKey = "key"; var lastResponse = Substitute.For <RestClient.APIResponse>(new HttpResponseMessage() { Content = new StringContent("something", Encoding.UTF8), StatusCode = HttpStatusCode.Created }); _restClient.LastResponse.Returns(lastResponse); _restClient.PostAsync <AssessmentShortResponse>(Arg.Any <string>(), Arg.Any <HttpRequestMessage>()) .ReturnsForAnyArgs(new AssessmentShortResponse { CreatedDate = DateTime.Now, SessionId = "sesionId", Salt = "salt", PartitionKey = "p-key" } ); IDysacSessionReader dysacService = new DysacService(_log, _restClient, _dysacServiceSetings, _oldDysacServiceSetings, _sessionClient); await dysacService.InitiateDysacOnly(); }
public void When_InitiateDysacOnlyWithErrors_ThrowException() { var userSession = new DfcUserSession(); userSession.PartitionKey = "key"; var restClient = Substitute.For <IRestClient>(); var lastResponse = Substitute.For <RestClient.APIResponse>(new HttpResponseMessage() { Content = new StringContent("something", Encoding.UTF8), StatusCode = HttpStatusCode.BadRequest }); restClient.LastResponse.Returns(lastResponse); restClient.PostAsync <AssessmentShortResponse>(apiPath: "", content: null).ReturnsForAnyArgs(new AssessmentShortResponse() { CreatedDate = DateTime.Now, SessionId = "sesionId", Salt = "salt", PartitionKey = "p-key" }); IDysacSessionReader dysacService = new DysacService(_log, restClient, _dysacServiceSetings, _oldDysacServiceSetings, _sessionClient); Assert.ThrowsAsync <DysacException>(() => dysacService.InitiateDysacOnly()); }