public void NotCallAlertScreen_WhenThereIsNoPurchaserToAlert() { // Arrange var alertScreen = Mock.Of <IAlertScreen>(); var purchaser = new Purchaser(alertScreen, _mediator); // Act _mediator.AddPurchaser(purchaser); purchaser.Complete(_product); // Assert Mock.Get(alertScreen).Verify(asc => asc.ShowMessage(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public void AlertScreen_WhenOnePurchaserCompletesTransaction() { // Arrange var alertScreenForCompletedPurchaser = new Mock <IAlertScreen>(); var alertScreenForActivePurchaser = new Mock <IAlertScreen>(); var completedPurchaser = new Purchaser(alertScreenForCompletedPurchaser.Object, _mediator); var activePurchaser = new Purchaser(alertScreenForActivePurchaser.Object, _mediator); // Act _mediator.AddPurchaser(completedPurchaser); _mediator.AddPurchaser(activePurchaser); completedPurchaser.Complete(_product); // Assert using (new FluentAssertions.Execution.AssertionScope("purchaser")) { alertScreenForActivePurchaser.Verify(sc => sc.ShowMessage(_product.Item, _product.Location)); alertScreenForCompletedPurchaser.Verify(sc => sc.ShowMessage(It.IsAny <string>(), It.IsAny <string>()), Times.Never); } }