public async Task SlackUpdateMessage() { 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 }) .Verifiable(); var httpClient = new HttpClient(handlerMock.Object) { BaseAddress = new Uri("http://test.com/"), }; var expectedResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK }; var slackPoster = new SlackPoster(httpClient); var actualResponse = await slackPoster.UpdateMessage(new JObject(), ""); Assert.Equal(expectedResponse.StatusCode, actualResponse.StatusCode); }
public void PostMessageTest() { ProductDetails productDetails = new ProductDetails { ScrapedBy = new ShelflifeScraper(), Name = "Vans x Van Gogh UA SK8-Hi - Almond Blossom/True White", Url = "https://www.shelflife.co.za/products/Vans-x-Van-Gogh-UA-SK8-Hi-Almond-Blossom-True-White", Price = 1399.00, ImageUrl = "https://www.shelflife.co.za/pics/product/large/vn0a38geubl-side.jpg", Id = "https://www.shelflife.co.za/products/Vans-x-Van-Gogh-UA-SK8-Hi-Almond-Blossom-True-White", Currency = "£", SizesList = new List <StringPair> { new StringPair() { Key = "L", Value = "1" }, new StringPair() { Key = "XL", Value = "1" }, new StringPair() { Key = "XXL", Value = "1" } } }; var task = new SlackPoster().PostMessage("https://hooks.slack.com/services/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", productDetails, CancellationToken.None); Debug.WriteLine(task.Result.Content.ReadAsStringAsync().Result); task.Result.EnsureSuccessStatusCode(); }
public HealthChecks(IDBFacade dbLeads, HttpClient client = null) { _dbLeads = dbLeads; _client = client ?? new HttpClient(); _slackApi = new SlackPoster(_client); _closeApi = new ClosePoster(_client); }
public Utility(IDBFacade dbLeads, IDBFacade dbSkills, HttpClient client = null) { _dbLeads = dbLeads; _dbSkills = dbSkills; _client = client ?? new HttpClient(); _slackApi = new SlackPoster(_client); _closeApi = new ClosePoster(_client); }