Example #1
0
        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();
        }
Example #2
0
        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();
        }
Example #3
0
        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();
 }
Example #5
0
 public void Stop() => simulator.Stop();
Example #6
0
 public void BaseTearDown()
 {
     server.Stop();
 }
Example #7
0
 public void Stop()
 {
     _simulator.Stop();
 }
Example #8
0
 public void TearDown()
 {
     _slackApi.Stop();
 }
Example #9
0
 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();
 }