Exemple #1
0
        public void SetupApiRequest(string path, HttpStatusCode code, string expectedJson, TimeSpan?time = null)
        {
            IApiReponseMocker response = new IApiReponseMocker();

            response.Setup(code, expectedJson, time);
            if (string.IsNullOrEmpty(path))
            {
                Mock.Setup(x => x.MakeApiRequestAsync(It.IsAny <string>())).ReturnsAsync(response.Response, time ?? AsyncDelay);
            }
            else
            {
                Mock.Setup(x => x.MakeApiRequestAsync(It.Is <string>(s => s == path))).ReturnsAsync(response.Response, time ?? AsyncDelay);
            }
        }
Exemple #2
0
        public void SetupAuth(bool valid, TimeSpan?time = null)
        {
            IApiReponseMocker response = new IApiReponseMocker();

            if (valid)
            {
                response.Setup(HttpStatusCode.OK, "{\"access_token\":\"EUDMYmwlmK3JM6ZKf54hHhNSRxd0IMxFNL\",\"token_type\":\"bearer\",\"expires_in\":86399,\"sub\":\"7cface7352224419a5678ba897d81af1\"}", time ?? AsyncDelay);
            }
            else
            {
                response.Setup(HttpStatusCode.Forbidden, "{\"AnyError\":\"Ooops\",\"token_type\":\"crash\",\"expires_in\":0,\"sub\":\"0\"}", time ?? AsyncDelay);
            }
            Mock.Setup(x => x.RequestAccessTokenAsync()).ReturnsAsync(response.Response, time ?? AsyncDelay);
        }