public async ValueTask SetReadValue(string value, DateTime timestamp) { //Logger?.LogTrace("SetReadValue: " + value); Value = value; Timestamp = timestamp; if (OldValue.Equals(Value)) { } else { OldValue = Value; //if (Invoke && (InputOutput.Equals("R") || InputOutput.Equals("RW"))) //{ //Logger.Trace("Domain Tag: " + Name + " - " + Value); //TagGroup.EventBus?.Publish(TagReadEvent); if (NotifierMediatorService != null /*&& Invoke*/) { //Logger.LogCritical("Domain Tag Publish! " + Name + " " + Value); await NotifierMediatorService .NotifyAsync(new TagValueChanged( /*Logger,*/ this, Name, Value, Timestamp)) .ConfigureAwait(false); //Logger.LogTrace("Domain Tag Publish! " + Name + " " + Value); } //} } }//SetReadValue
public async Task NotifierMediatorServiceWithNullMessageShouldRaiseArgumentNullException() { //Arrange var mockMediator = new Mock <IMediator>(); mockMediator.Setup(m => m.Publish(It.IsAny <object>(), It.IsAny <CancellationToken>())).Verifiable(); //Act INotifierMediatorService notifierMediatorService = new NotifierMediatorService(mockMediator.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => notifierMediatorService.Notify <object>(null)); }
public async Task NotifierMediatorServiceShouldSendNotifications() { //Arrange var message = new NotificationMessage <string> { Message = "notifyText" }; var mockMediator = new Mock <IMediator>(); mockMediator.Setup(m => m.Publish(It.IsAny <object>(), It.IsAny <CancellationToken>())).Verifiable(); //Act INotifierMediatorService notifierMediatorService = new NotifierMediatorService(mockMediator.Object); await notifierMediatorService.Notify(message); //Assert mockMediator.Verify(m => m.Publish(message, It.IsAny <CancellationToken>()), Times.Once); }