public void GetConfigurationTest() { // arrage var httpClient = new HttpClient(); // act IWebChatService webChatService = new WebChatService(httpClient, EnvironmentName, ContentRootPath); WebChatConfig config = webChatService.GetConfiguration(); // assert Assert.Equal(configuration.Secret, config.Secret); }
public async void GetDirectLineTokenTest() { // arrage var expectedGenerateResponse = new GenerateResponse() { conversationId = "conversation_id", expires_in = 100, token = "token" }; var jsonExpectedGenerateResponse = JsonConvert.SerializeObject(expectedGenerateResponse); var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) .ReturnsAsync(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(jsonExpectedGenerateResponse), }) .Verifiable(); var httpClient = new HttpClient(handlerMock.Object) { BaseAddress = new Uri("http://localhost/") }; // act IWebChatService webChatService = new WebChatService(httpClient, EnvironmentName, ContentRootPath); GenerateResponse response = await webChatService.GetDirectLineTokenAsync(configuration.Secret); // assert Assert.Equal(expectedGenerateResponse.conversationId, response.conversationId); Assert.Equal(expectedGenerateResponse.expires_in, response.expires_in); Assert.Equal(expectedGenerateResponse.token, response.token); }