public async Task LoginAsyncTest() { StubISettings settings = new StubISettings(); String authValue = null; settings.AuthzCookieValue_Get(() => authValue); settings.AuthzCookieValue_Set((v) => authValue = v); IServerContext context = new ServerContext(settings); settings.ServerUrl_Get(() => new Uri("http://*****:*****@test.com", "testtest"); } catch(ServerException se) { thrown = true; Assert.AreEqual(503, se.StatusCode); } Assert.IsTrue(thrown); settings.ServerUrl_Get(() => new Uri("http://*****:*****@test.com", null); } catch(ArgumentNullException ane) { Assert.AreEqual("password", ane.ParamName); thrown = true; } Assert.IsTrue(thrown, "Exception not thrown"); var result = await context.LoginAsync("*****@*****.**", "not known"); Assert.AreEqual(false, result.Item1); result = await context.LoginAsync("*****@*****.**", "testtest"); Assert.AreEqual(true, result.Item1); Assert.AreEqual("Test User", result.Item2); Assert.IsNotNull(authValue); Assert.IsFalse(String.IsNullOrWhiteSpace(authValue)); }
public async Task GetRolesAsyncTest() { StubISettings settings = new StubISettings(); settings.ServerUrl_Get(() => new Uri("http://*****:*****@test.com", "testtest"); actual = await context.GetRolesAsync(); Assert.IsNotNull(actual); Assert.IsTrue(actual.Count > 0); Assert.IsTrue(actual.Contains("Controller")); }