Пример #1
0
 public void Setup()
 {
     _simulator = new FluentSimulator("http://localhost:8050/");
     _simulator.Get("/api/v2/users").Responds("{Success: true}");
     _simulator.Start();
     _apiGateway = new ApiGateway("http://localhost:8050/");
 }
Пример #2
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();
        }
Пример #3
0
        public void SetUp()
        {
            _classUnderTest  = new GovNotifyNotificationsGateway();
            _govNotifyUrl    = Environment.GetEnvironmentVariable("GOV_NOTIFY_URL");
            _govNotifyApiKey = Environment.GetEnvironmentVariable("GOV_NOTIFY_API_KEY");

            SetupEnvironmentVariables("http://localhost:3000/", "cafe");

            _simulator = new FluentSimulator("http://localhost:3000/");
            _simulator.Post("/v2/notifications/email").Responds("{}");
            _simulator.Start();
        }
Пример #4
0
        public void CanUseCustomSerializer()
        {
            Sim.Stop();
            Sim = new FluentSimulator(BaseAddress, new JsonSerializerSettings
            {
                Converters = { new StringEnumConverter() }
            });
            Sim.Start();

            Sim.Post("/test")
            .Responds(new TestEnumClass());

            MakePostRequest("/test", "").Content.ShouldBe(@"{""TestEnumField"":""V2""}");
        }
Пример #5
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();
        }
Пример #6
0
        public void CanGetPreviousBodyWithCustomSerializer()
        {
            Sim.Stop();
            Sim = new FluentSimulator(BaseAddress, new JsonSerializerSettings
            {
                Converters = { new AllFieldsReplacementConverter() }
            });
            Sim.Start();

            Sim.Post("/test");

            MakePostRequest("/test", @"{""TestField"":""original""}");

            Sim.ReceivedRequests[0].BodyAs <TestObject>().TestField.ShouldBe("REPLACEMENT");
        }
Пример #7
0
            public void SetUp()
            {
                _slackApi     = new FluentSimulator(Address);
                _slackGateway = new SlackGateway(Address, Token);

                var json = File.ReadAllText(
                    Path.Combine(
                        AppDomain.CurrentDomain.BaseDirectory,
                        "Gateway/ApiEndpointResponse/ExcludedSlackUsersResponse.json"
                        )
                    );

                _slackApi.Get("/api/users.list").Responds(json);

                _slackApi.Start();

                _response = _slackGateway.RetrieveBillablePeople();
            }
        private static void HandleSetUp()
        {
            _slackApi     = new FluentSimulator(SlackApiAddress);
            _slackGateway = new SlackGateway(SlackApiAddress, "xxxx-xxxxxxxxx-xxxx");
            _sendReminder = new SendReminder(_slackGateway);

            var slackGetUsersResponse = File.ReadAllText(
                Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory,
                    "../../../ApiEndpointResponse/SlackUsersResponse.json"
                    )
                );

            _slackApi.Get("/" + SlackApiUsersPath).Responds(slackGetUsersResponse);

            _slackApi.Post("/" + SlackApiPostMessagePath).Responds(new { ok = true });

            _slackApi.Start();
        }
        public void Setup()
        {
            Environment.SetEnvironmentVariable("GOV_NOTIFY_URL", GovNotifyHost);
            Environment.SetEnvironmentVariable("GOV_NOTIFY_API_KEY", GovNotifyApiKey);

            _govNotifySimulator = new FluentSimulator(GovNotifyHost);
            _govNotifySimulator.Start();
            _govNotifySimulator.Post("/v2/notifications/email").Responds("{}");

            var assetRegister = new AssetRegister();
            var importUseCase = assetRegister.Get <IImportAssetsUseCase>();
            var textSplitter  = assetRegister.Get <ITextSplitter>();
            var getAssetRegisterVersionUseCase = assetRegister.Get <IGetAssetRegisterVersionsUseCase>();
            var assetRegisterUploadNotifier    = assetRegister.Get <IAssetRegisterUploadProcessedNotifier>();
            var backgroundProcessor            = assetRegister.Get <IBackgroundProcessor>();

            _assetRegisterContext = assetRegister.Get <AssetRegisterContext>();
            _classUnderTest       = new AssetRegisterVersionController(getAssetRegisterVersionUseCase, importUseCase, textSplitter, assetRegisterUploadNotifier, backgroundProcessor);
        }
Пример #10
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);
        }
Пример #11
0
 public void SetUp()
 {
     Sim = new FluentSimulator(BaseAddress);
     Sim.Start();
 }
Пример #12
0
 public SlackSimulator(string address)
 {
     _simulator      = new FluentSimulator(address);
     SpyMethodCalled = false;
 }