Ejemplo n.º 1
0
        public void TestWebPubSubConnection_Scheme(string connectionString, string expectedBaseUrl)
        {
            var service = new WebPubSubService(connectionString, "testHub");

            var clientConnection = service.GetClientConnection();

            Assert.NotNull(clientConnection);
            Assert.AreEqual(expectedBaseUrl, clientConnection.BaseUrl);
        }
        public void TestWebPubSubConnection_Scheme(string connectionString, string expectedBaseUrl)
        {
            var service = new WebPubSubService(connectionString, "testHub");

            var clientConnection = service.GetClientConnection();

            Assert.NotNull(clientConnection);
            Assert.AreEqual(expectedBaseUrl, clientConnection.BaseUrl);
            Assert.NotNull(clientConnection.AccessToken);

            var absoluteUrl = $"{expectedBaseUrl}?access_token={clientConnection.AccessToken}";

            Assert.AreEqual(absoluteUrl, clientConnection.Url);
        }
        public async Task AddAsync_WebPubSubEvent_SendAll()
        {
            var mockClient = new Mock <WebPubSubServiceClient>();
            var service    = new WebPubSubService(mockClient.Object);
            var collector  = new WebPubSubAsyncCollector(service);

            var message = "new message";
            await collector.AddAsync(new SendToAll
            {
                Message  = BinaryData.FromString(message),
                DataType = MessageDataType.Text
            });

            mockClient.Verify(c => c.SendToAllAsync(It.IsAny <RequestContent>(), It.IsAny <ContentType>(), It.IsAny <string[]>(), It.IsAny <RequestOptions>()), Times.Once);
            mockClient.VerifyNoOtherCalls();

            mockClient.VerifyAll();
        }