Esempio n. 1
0
        public async void when_http_client_returns_non_json()
        {
            var mockHttp = new Mock <IHttp>();

            mockHttp
            .Setup(http => http.Get(It.IsAny <string>()))
            .Returns(Task.FromResult <HttpGetResult>(new HttpGetResult {
                Body = "not-json"
            }));

            var sut = new Slack(mockHttp.Object);

            await Assert.ThrowsAsync <Exception>(async() => await sut.GetWebsocketUrl(""));
        }
Esempio n. 2
0
        public async void when_requesting_a_websocket_url()
        {
            var url             = "best-url-eva";
            var helloRTMSession = new HelloRTMSession {
                url = url
            };
            var mockHttp = new Mock <IHttp>();

            mockHttp
            .Setup(http => http.Get(It.IsAny <string>()))
            .Returns(Task.FromResult <HttpGetResult>(new HttpGetResult {
                Body = JSON.Serialize(helloRTMSession)
            }));

            var sut = new Slack(mockHttp.Object);

            var actual = await sut.GetWebsocketUrl("");

            Assert.Equal(url, actual);
        }