public IEnumerator CheckAccessTokenAsync_WebResponseFailed_ReturnsFalse() { LearningLayersOidcProvider lloidc = new LearningLayersOidcProvider(); IRestConnector restConnector = A.Fake <IRestConnector>(); A.CallTo(() => restConnector.GetAsync(A <string> .Ignored)) .Returns(new WebResponse <string>("This is a simulated error", 400)); lloidc.RestConnector = restConnector; LogAssert.Expect(LogType.Error, new Regex(@"\w*This is a simulated error\w*")); Task <bool> task = lloidc.CheckAccessTokenAsync(""); yield return(AsyncTest.WaitForTask(task)); bool res = task.Result; Assert.IsFalse(res); }
public IEnumerator CheckAccessTokenAsync_WebResponseSuccessful_ReturnsTrue() { LearningLayersOidcProvider lloidc = new LearningLayersOidcProvider(); IRestConnector restConnector = A.Fake <IRestConnector>(); A.CallTo(() => restConnector.GetAsync(A <string> .Ignored)) .Returns(new WebResponse <string>("answer", null, 200)); lloidc.RestConnector = restConnector; LearningLayersUserInfo userInfo = new LearningLayersUserInfo("tester", "*****@*****.**", "Tester"); IJsonSerializer serializer = A.Fake <IJsonSerializer>(); A.CallTo(() => serializer.FromJson <LearningLayersUserInfo>(A <string> .Ignored)) .Returns(userInfo); lloidc.JsonSerializer = serializer; Task <bool> task = lloidc.CheckAccessTokenAsync(""); yield return(AsyncTest.WaitForTask(task)); bool res = task.Result; Assert.IsTrue(res); }