using NSubstitute; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications; using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories; namespace ZB.MOM.WW.ScadaBridge.NotificationOutbox.Tests; /// /// Factory for the outbox repository substitute used across these tests. /// /// /// and /// both /// return whether the targeted UPDATE actually matched a row — false is /// the "this notification no longer exists (or, for the CAS variant, is no /// longer Parked)" signal the operator retry/discard handlers turn into a /// not-found / already-progressed reply. NSubstitute's default for /// Task<bool> is false, i.e. the failure answer, so an /// unconfigured substitute would silently put every test on the failure path. /// Tests that want a healthy store take one from here; the vanished-row and /// lost-CAS tests configure Returns(false) for themselves. /// internal static class OutboxRepositorySubstitute { /// Creates a substitute whose writes report that the row was found. public static INotificationOutboxRepository Healthy() { var repository = Substitute.For(); repository .UpdateAsync(Arg.Any(), Arg.Any()) .Returns(true); repository .TryUpdateFromParkedAsync(Arg.Any(), Arg.Any()) .Returns(true); return repository; } }