public async void AttachedClientLogout() { var testContext = TestContext.MockUp(accessValidTime: 0.1); var domain0Context = new AuthenticationContext( domain0ClientEnvironment: testContext.ClientScopeMock.Object, externalStorage: testContext.LoginInfoStorageMock.Object); var attachedClientMock = new Mock <ITestClient>(); var attachedClient = attachedClientMock.Object; var attachedEnvironmentMock = new Mock <IClientScope <ITestClient> >(); attachedEnvironmentMock .Setup(callTo => callTo.Client) .Returns(() => attachedClient); var profile = await domain0Context.LoginByPhone(123, "2"); Assert.NotNull(profile); var proxy = domain0Context.AttachClientEnvironment(attachedEnvironmentMock.Object); Assert.NotNull(proxy); domain0Context.Logout(); attachedEnvironmentMock .VerifySet(env => env.Token = It.Is <string>(x => string.IsNullOrWhiteSpace(x)), Times.Once); }
public async void Logout() { var testContext = TestContext.MockUp(); using (var domain0Context = new AuthenticationContext( domain0ClientEnvironment: testContext.ClientScopeMock.Object, externalStorage: testContext.LoginInfoStorageMock.Object)) { Assert.False(domain0Context.IsLoggedIn); var profile = await domain0Context.LoginByEmail("email", "2"); Assert.NotNull(profile); testContext.ClientScopeMock .VerifySet(callTo => callTo.Token = It.Is <string>(s => !string.IsNullOrWhiteSpace(s)), Times.Once); Assert.True(domain0Context.IsLoggedIn); domain0Context.Logout(); Assert.False(domain0Context.IsLoggedIn); testContext.ClientScopeMock .VerifySet(callTo => callTo.Token = It.Is <string>(s => string.IsNullOrWhiteSpace(s)), Times.Exactly(2)); testContext.LoginInfoStorageMock .Verify(callTo => callTo.Delete(), Times.Once); } }
public async void AttachedTokenStoreLogout() { var testContext = TestContext.MockUp(accessValidTime: 0.1); var domain0Context = new AuthenticationContext( domain0ClientEnvironment: testContext.ClientScopeMock.Object, externalStorage: testContext.LoginInfoStorageMock.Object); var attachedTokenStoreMock = new Mock <ITestStore>(); var profile = await domain0Context.LoginByPhone(123, "2"); Assert.NotNull(profile); domain0Context.AttachTokenStore(attachedTokenStoreMock.Object); domain0Context.Logout(); attachedTokenStoreMock .VerifySet(env => env.Token = It.Is <string>(x => string.IsNullOrWhiteSpace(x)), Times.Once); }