Esempio n. 1
0
        public async Task GetLoginServerInformation_ReturnsLoginInfoResponse_WhenRequestsSucceed()
        {
            Exception thrownException = null;

            Assert.IsTrue(_fakeBasicInfoJsonResponse.Contains(_fakeLoginAddress));

            var fakeLoginServerInfo = new LoginInfoResponse
            {
                Prompts = new System.Collections.Generic.Dictionary <string, string[]>
                {
                    { "username", new[] { "text", "Email" } },
                    { "password", new[] { "password", "Password" } },
                }
            };

            MockedRequest cfBasicInfoRequest = _mockHttp.Expect(_fakeCfApiAddress + "/")
                                               .Respond("application/json", _fakeBasicInfoJsonResponse);

            MockedRequest loginServerInfoRequest = _mockHttp.Expect(_fakeLoginAddress + "/login")
                                                   .Respond("application/json", JsonConvert.SerializeObject(fakeLoginServerInfo));

            try
            {
                var result = await _sut.GetLoginServerInformation(_fakeCfApiAddress);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            Assert.IsNull(thrownException);

            Assert.AreEqual(1, _mockHttp.GetMatchCount(cfBasicInfoRequest));
            Assert.AreEqual(1, _mockHttp.GetMatchCount(loginServerInfoRequest));
        }