Пример #1
0
        public async void ClientDetach()
        {
            var testContext = TestContext.MockUp();

            var domain0Context = new AuthenticationContext(
                domain0ClientEnvironment: testContext.ClientScopeMock.Object,
                externalStorage: testContext.LoginInfoStorageMock.Object);

            var attachedTokenStoreMock = new Mock <ITestStore>();

            domain0Context.AttachTokenStore(attachedTokenStoreMock.Object);

            var profile = await domain0Context.LoginByPhone(123, "2");

            Assert.NotNull(profile);

            attachedTokenStoreMock
            .VerifySet(env =>
                       env.Token = It.Is <string>(s => string.IsNullOrWhiteSpace(s)),
                       Times.Once);

            domain0Context.DetachTokenStore(attachedTokenStoreMock.Object);

            profile = await domain0Context.LoginByPhone(123, "2");

            Assert.NotNull(profile);

            attachedTokenStoreMock
            .VerifySet(env =>
                       env.Token = It.Is <string>(s => string.IsNullOrWhiteSpace(s)),
                       Times.Once);
        }