public async Task GetSignInResourceAsyncWithNullConnectionNameShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await userToken.GetSignInResourceAsync(null, new Activity(), "final-redirect", CancellationToken.None);
            });
        }
        public async Task GetUserTokenAsyncWithNullConnectionNameShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await userToken.GetUserTokenAsync(UserId, null, ChannelId, MagicCode, CancellationToken.None);
            });
        }
        public async Task GetTokenStatusAsyncWithNullUserIdShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await userToken.GetTokenStatusAsync(null, ChannelId, "filter", CancellationToken.None);
            });
        }
        public async Task GetSignInResourceAsyncOfDisposedTokenShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            userToken.Dispose();

            await Assert.ThrowsAsync <ObjectDisposedException>(async() =>
            {
                await userToken.GetSignInResourceAsync(ConnectionName, new Activity(), "final-redirect", CancellationToken.None);
            });
        }
        public async Task GetUserTokenAsyncOfDisposedTokenShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            userToken.Dispose();

            await Assert.ThrowsAsync <ObjectDisposedException>(async() =>
            {
                await userToken.GetUserTokenAsync(UserId, ConnectionName, ChannelId, MagicCode, CancellationToken.None);
            });
        }
        public async Task ExchangeTokenAsyncWithNullUserIdShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            var tokenExchange = new TokenExchangeRequest();

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await userToken.ExchangeTokenAsync(null, ChannelId, ChannelId, tokenExchange, CancellationToken.None);
            });
        }
        public async Task GetAadTokensAsyncWithNullConnectionNameShouldThrow()
        {
            var credentials = new TestCredentials();

            var userToken = new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null);

            string[] resourceUrls = { "https://test.url" };

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await userToken.GetAadTokensAsync(UserId, null, resourceUrls, ChannelId, CancellationToken.None);
            });
        }
Пример #8
0
        private void SignalR_Reading_Writing(String url, SignalRMode mode)
        {
            TestCredentials credentials = new TestCredentials()
            {
                Name = "Test"
            };
            TestServiceInformation serviceInfo = new TestServiceInformation()
            {
                ServiceId = "My Test Service"
            };

            var registeredService = ResonanceServiceFactory.Default.RegisterService <TestCredentials, TestServiceInformation, TestAdapterInformation>(credentials, serviceInfo, url, mode);

            Assert.AreSame(registeredService.Credentials, credentials);
            Assert.AreSame(registeredService.ServiceInformation, serviceInfo);
            Assert.AreEqual(registeredService.Mode, mode);

            bool connected = false;

            ResonanceTransporter serviceTransporter = new ResonanceTransporter();

            registeredService.ConnectionRequest += (_, e) =>
            {
                Assert.IsTrue(e.RemoteAdapterInformation.Information == "No information on the remote adapter");
                serviceTransporter.Adapter = e.Accept();
                serviceTransporter.Connect();
                connected = true;
            };

            var remoteServices = ResonanceServiceFactory.Default.GetAvailableServices <TestCredentials, TestServiceInformation>(credentials, url, mode);

            Assert.IsTrue(remoteServices.Count == 1);

            var remoteService = remoteServices.First();

            Assert.AreEqual(remoteService.ServiceId, registeredService.ServiceInformation.ServiceId);

            ResonanceTransporter clientTransporter = new ResonanceTransporter(new SignalRAdapter <TestCredentials>(credentials, url, remoteService.ServiceId, mode));

            clientTransporter.Connect();

            TestHelper.WaitWhile(() => !connected, TimeSpan.FromSeconds(30));

            TestUtils.Read_Write_Test(this, serviceTransporter, clientTransporter, false, 1000, 20);
        }
Пример #9
0
            public override Task <IConnectorClient> CreateAsync(string serviceUrl, string audience, CancellationToken cancellationToken)
            {
                var credentials = new TestCredentials(audience ?? "test-token");

                return(Task.FromResult((IConnectorClient) new ConnectorClient(new Uri(serviceUrl), credentials, null, disposeHttpClient: true)));
            }
        public void ConstructorShouldWork()
        {
            var credentials = new TestCredentials();

            Assert.NotNull(new UserTokenClientImpl(AppId, credentials, OauthEndpoint, null, null));
        }