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(); }
public async Task AddAsync_WebPubSubEvent_SendAll() { var serviceMock = new Mock <IWebPubSubService>(); var collector = new WebPubSubAsyncCollector(serviceMock.Object); var message = "new message"; await collector.AddAsync(new SendToAll { Message = BinaryData.FromString(message), DataType = MessageDataType.Text }); serviceMock.Verify(c => c.SendToAll(It.IsAny <SendToAll>()), Times.Once); serviceMock.VerifyNoOtherCalls(); var actualData = (SendToAll)serviceMock.Invocations[0].Arguments[0]; Assert.AreEqual(MessageDataType.Text, actualData.DataType); Assert.AreEqual(message, actualData.Message.ToString()); }