public void CanDeliverSlackMessageWithCorrectButton() { FluentSimulator slackSimulator = new FluentSimulator("http://localhost:8081/"); string request_url_path = "/actions"; slackSimulator.Post(request_url_path).Responds(""); slackSimulator.Start(); var started = false; var spyToggleWorkshopAttendance = new SpyToggleWorkshopAttendance(); var spyGetWorkshop = new StubGetWorkshop(); spyGetWorkshop.attendees.Add("Bing"); var deliveryMechanism = new DeliveryMechanism(spyToggleWorkshopAttendance, spyGetWorkshop, "5054"); var thread = new Thread(() => { deliveryMechanism.Run(() => { started = true; }); }); thread.Start(); SpinWait.SpinUntil(() => started); SlackButtonPayload payload = new SlackButtonPayload() { User = new User() { Name = "Bing", UserID = "123" }, Actions = new Actions[] { new Actions() { Value = "record3" } }, ResponseURL = "http://localhost:8081/actions" }; string firstjson = JsonConvert.SerializeObject(payload); var encoded = HttpUtility.UrlEncode(firstjson); var fakeSlackWebClient = new WebClient(); fakeSlackWebClient.UploadString("http://localhost:5054/attend", "POST", "payload=" + encoded); var requestReceivedBySlack = slackSimulator.ReceivedRequests; Assert.AreEqual("application/json", requestReceivedBySlack[0].ContentType); Assert.IsTrue(requestReceivedBySlack[0].RequestBody.Contains("Unattend")); slackSimulator.Stop(); }
public async Task ItUsesTheGovNotifyUrlEnvironmentVariable(string baseUrl) { SetupEnvironmentVariables(baseUrl, "cafe"); var simulator = new FluentSimulator(baseUrl); simulator.Start(); simulator.Post("/v2/notifications/email").Responds("{}"); await _classUnderTest.SendOneTimeLinkAsync(StubNotification(), CancellationToken.None); simulator.ReceivedRequests[0].Url.Should().Be($"{baseUrl}v2/notifications/email"); simulator.Stop(); }
private async Task <NotifyRequest> RequestAccessToApplication() { var simulator = new FluentSimulator("http://*****:*****@example.com", Url = "http://meow.cat/" }; await _authenticateUser.ExecuteAsync(request, CancellationToken.None); simulator.Stop(); NotifyRequest notifyRequest = simulator.ReceivedRequests[0].BodyAs <NotifyRequest>(); return(notifyRequest); }
public void TearDown() { _simulator.Stop(); }
public void Stop() => simulator.Stop();
public void BaseTearDown() { server.Stop(); }
public void Stop() { _simulator.Stop(); }
public void TearDown() { _slackApi.Stop(); }
public void TearDown() { Environment.SetEnvironmentVariable("GOV_NOTIFY_URL", _govNotifyUrl); Environment.SetEnvironmentVariable("GOV_NOTIFY_API_KEY", _govNotifyApiKey); _simulator.Stop(); }
public void CleanUp() { _simulator.Stop(); }
public void TearDown() { _govNotifySimulator.Stop(); }