public async Task ThenTheAddAppreticesTaskIsNotSavedIfCohortsHaveAlreadyBeenAdded() { //Arrange _messageContent = new AgreementSignedMessage(12, 2, "ACME Fireworks", 34, true, "Test User", "ABC123"); _mockMessage.Setup(x => x.Content).Returns(_messageContent); //Act await _processor.RunAsync(_tokenSource); //Assert _mediator.Verify(x => x.SendAsync(It.Is <SaveTaskCommand>(cmd => cmd.Type.Equals(TaskType.AddApprentices))), Times.Never()); }
public void Arrange() { _subscriptionFactory = new Mock <IMessageSubscriberFactory>(); _subscriber = new Mock <IMessageSubscriber <AgreementSignedMessage> >(); _messageContent = new AgreementSignedMessage(); _mockMessage = new Mock <IMessage <AgreementSignedMessage> >(); _mockMessage.Setup(x => x.Content).Returns(_messageContent); _mediator = new Mock <IMediator>(); _tokenSource = new CancellationTokenSource(); _processor = new SignedEmployerAgreementMessageProcessor(_subscriptionFactory.Object, Mock.Of <ILog>(), _mediator.Object); _subscriptionFactory.Setup(x => x.GetSubscriber <AgreementSignedMessage>()).Returns(_subscriber.Object); _subscriber.Setup(x => x.ReceiveAsAsync()) .ReturnsAsync(() => _mockMessage.Object) .Callback(() => { _tokenSource.Cancel(); }); }