private void btnServStart_Click(object sender, EventArgs e) { AcceptEvent += new AcceptClient(AcceptEventHandler); CloseEvent += new CloseClient(CloseEventHandler); lvServState.Items.Add("연결 대기 중..."); clientThread = new Thread(new ThreadStart(Accept)); clientThread.IsBackground = true; clientThread.Start(); }
public async Task CloseGetListOfCustomersTest() { var expectedJson = $@"{{ ""blocks"": [ {{ ""text"": {{ ""type"": ""plain_text"", ""text"": "" "" }}, ""type"": ""section"" }}, {{ ""text"": {{ ""type"": ""plain_text"", ""text"": "" "" }}, ""type"": ""section"" }}, {{ ""text"": {{ ""type"": ""mrkdwn"", ""text"": ""*header*\nhttp://test.com"" }}, ""type"": ""section"", ""block_id"": ""msg_header"" }}, {{ ""block_id"": ""actions"", ""elements"": [ {{ ""placeholder"": {{ ""type"": ""plain_text"", ""text"": ""Customer"" }}, ""options"": [ {{ ""text"": {{ ""type"": ""plain_text"", ""text"": ""DSB"" }}, ""value"": ""DSB"" }}, {{ ""text"": {{ ""type"": ""plain_text"", ""text"": ""Efio"" }}, ""value"": ""Efio"" }} ], ""type"": ""static_select"", ""action_id"": ""customer_select"" }}, {{ ""type"": ""button"", ""action_id"": ""qualifyLead_btn"", ""text"": {{ ""type"": ""plain_text"", ""text"": ""Qualify Lead"" }}, ""style"": ""primary"" }} ], ""type"": ""actions"" }}, {{ ""type"": ""divider"" }} ] }}"; JObject expectedJObject = JObject.Parse(expectedJson); var closeJson = $@"{{ ""data"": [ {{ ""display_name"" : ""DSB"", ""id"" : ""DSB"" }}, {{ ""display_name"" : ""Efio"", ""id"" : ""Efio"" }} ] }}"; JObject expectedCloseJObject = JObject.Parse(closeJson); 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(expectedCloseJObject.ToString()) }) .Verifiable(); var httpClient = new HttpClient(handlerMock.Object) { BaseAddress = new Uri("http://test.com/") }; ICloseClient closeApi = new CloseClient(httpClient); var function = new Function(); JObject payload = await function.BuildSlackPayload("header", "http://test.com", closeApi); Assert.True(JToken.DeepEquals(expectedJObject, payload)); }
public TcpClient(CloseClient closeClient) { m_clientCloseEvent = closeClient; }