protected MockMessage(TMessage instanceMessage) { this.repository = Pleasure.Mock <IRepository>(); IoCFactory.Instance.StubTryResolve(this.repository.Object); this.eventBroker = Pleasure.MockStrict <IEventBroker>(); IoCFactory.Instance.StubTryResolve(this.eventBroker.Object); Original = instanceMessage; }
protected MockMessage(TMessage instanceMessage) { this.unitOfWork = Pleasure.MockStrictAsObject <IUnitOfWork>( mock => { mock.Setup(x => x.GetSession()).Returns(Pleasure.Generator.String()); mock.Setup(x => x.Open()); }); instanceMessage.Setting = new MessageExecuteSetting(); instanceMessage.Setting.SetValue("unitOfWork", unitOfWork); this.repository = Pleasure.Mock <IRepository>(mock => mock.Setup(r => r.SetProvider(unitOfWork))); IoCFactory.Instance.StubTryResolve(this.repository.Object); this.eventBroker = Pleasure.MockStrict <IEventBroker>(); IoCFactory.Instance.StubTryResolve(this.eventBroker.Object); this.dispatcher = Pleasure.MockStrict <IDispatcher>(mock => { mock.StubPush <CommandBase>(@base => { bool isAny = false; foreach (var action in this.actions) { try { action(@base); isAny = true; } catch (Exception) { } } isAny.ShouldBeTrue(); }); }); IoCFactory.Instance.StubTryResolve(this.dispatcher.Object); instanceMessage.Setting.SetValue("outerDispatcher", this.dispatcher.Object); Original = instanceMessage; }