public ShellViewModel(ISomeRepository repository, IConfirmer confirmer) { if (confirmer == null) { throw new ArgumentNullException("confirmer"); } _confirmer = confirmer;
private void Initialize(Action <IServiceBusConfigurator> busConfigureAction) { _publishSettings.Validate(); if (_publishSettings.UsePublisherConfirms) { Action <IServiceBusConfigurator> publisherConfirmConfigureAction = configurator => { busConfigureAction(configurator); configurator.UsePublisherConfirms(_publishSettings); }; _serviceBus = ServiceBusFactory.New(publisherConfirmConfigureAction); } else { _serviceBus = ServiceBusFactory.New(busConfigureAction); } _confirmer = _publishSettings.Confirmer; _messageRepository = UnconfirmedMessageRepositoryFactory.Create(_publishSettings); _confirmer.PublicationFailed += OnPublicationFailed; _confirmer.PublicationSucceeded += OnPublicationSucceeded; _lastMessageBufferStoreTimestamp = DateTime.UtcNow.Ticks; _lastPublishRetryTimestamp = DateTime.UtcNow.Ticks; _checkOfflineTasksTimer = new Timer(CheckOfflineTasks, null, _publishSettings.TimerCheckInterval, _publishSettings.TimerCheckInterval); }
private static IConfirmer CreateMockConfirmerWithExpectation(MockRepository mockRepository, AbstractConstraint messageConstraint, bool confirmReturnValue) { IConfirmer confirmer = mockRepository.StrictMock <IConfirmer>(); Expect.Call(() => confirmer.Confirm(null, null)) .Constraints(messageConstraint, Is.NotNull()) .Do((Delegates.Action <string, ConfirmationDelegate>)( (message, confirmationDelegate) => confirmationDelegate(confirmReturnValue))); return(confirmer); }
public void Test_Construct() { //---------------Set up test pack------------------- MockRepository mockRepository = new MockRepository(); IConfirmer confirmer = mockRepository.StrictMock <IConfirmer>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ConfirmingBusinessObjectDeletor confirmingBusinessObjectDeletor = new ConfirmingBusinessObjectDeletor(confirmer); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(IBusinessObjectDeletor), confirmingBusinessObjectDeletor); Assert.AreSame(confirmer, confirmingBusinessObjectDeletor.Confirmer); }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); try { _confirmer = new Controls.Confirmer.MessageBoxConfirmer(); DataContext = new TextManagerViewModel(_confirmer, this); ((TextManagerViewModel)DataContext).LoadItems(); } catch (Exception ex) { LogHelper.LogException(ex); } }
public void Test_Construct_WithCustomConfirmationMessageDelegate() { //---------------Set up test pack------------------- MockRepository mockRepository = new MockRepository(); IConfirmer confirmer = mockRepository.StrictMock <IConfirmer>(); Habanero.Util.Function <IBusinessObject, string> customConfirmationMessageDelegate = t => "aaa"; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ConfirmingBusinessObjectDeletor confirmingBusinessObjectDeletor = new ConfirmingBusinessObjectDeletor(confirmer, customConfirmationMessageDelegate); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(IBusinessObjectDeletor), confirmingBusinessObjectDeletor); Assert.AreSame(confirmer, confirmingBusinessObjectDeletor.Confirmer); Assert.AreSame(customConfirmationMessageDelegate, confirmingBusinessObjectDeletor.CustomConfirmationMessageDelegate); }
public void Test_DeleteBusinessObject_ConfirmationMessage() { //---------------Set up test pack------------------- MockRepository mockRepository = new MockRepository(); string boToString = TestUtil.GetRandomString(); string expectedMessage = string.Format("Are you certain you want to delete the object '{0}'", boToString); IConfirmer confirmer = CreateMockConfirmerWithExpectation(mockRepository, Is.Equal(expectedMessage), false); IBusinessObject boToDelete = new MockBOWithToString(boToString); ConfirmingBusinessObjectDeletor confirmingBusinessObjectDeletor = new ConfirmingBusinessObjectDeletor(confirmer); mockRepository.ReplayAll(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- confirmingBusinessObjectDeletor.DeleteBusinessObject(boToDelete); //---------------Test Result ----------------------- mockRepository.VerifyAll(); }
public void Test_DeleteBusinessObject_CustomConfirmationMessage() { //---------------Set up test pack------------------- MockRepository mockRepository = new MockRepository(); string expectedMessage = TestUtil.GetRandomString(); IConfirmer confirmer = CreateMockConfirmerWithExpectation(mockRepository, Is.Equal(expectedMessage), false); IBusinessObject boToDelete = mockRepository.StrictMock <IBusinessObject>(); ConfirmingBusinessObjectDeletor confirmingBusinessObjectDeletor = new ConfirmingBusinessObjectDeletor(confirmer, t => expectedMessage); mockRepository.ReplayAll(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- confirmingBusinessObjectDeletor.DeleteBusinessObject(boToDelete); //---------------Test Result ----------------------- mockRepository.VerifyAll(); }
///<summary> /// Constructs a new <see cref="ConfirmingBusinessObjectDeletor"/> with the specified <see cref="IConfirmer"/> /// and a delegate for constructing the confirmation message. ///</summary> ///<param name="confirmer">The <see cref="IConfirmer"/> to use to prompt the user for confirmation of the deletion.</param> ///<param name="customConfirmationMessageDelegate">The delegate to use for constructing the confirmation message that will be /// displayed to the user for a particular <see cref="IBusinessObject"/>.</param> public ConfirmingBusinessObjectDeletor(IConfirmer confirmer, Function<IBusinessObject, string> customConfirmationMessageDelegate) : this(confirmer) { CustomConfirmationMessageDelegate = customConfirmationMessageDelegate; }
///<summary> /// Constructs a new <see cref="ConfirmingBusinessObjectDeletor"/> with the specified <see cref="IConfirmer"/>. ///</summary> ///<param name="confirmer">The <see cref="IConfirmer"/> to use to prompt the user for confirmation of the deletion.</param> public ConfirmingBusinessObjectDeletor(IConfirmer confirmer) { Confirmer = confirmer; }
///<summary> /// Constructs a new <see cref="ConfirmingBusinessObjectDeletor"/> with the specified <see cref="IConfirmer"/> /// and a delegate for constructing the confirmation message. ///</summary> ///<param name="confirmer">The <see cref="IConfirmer"/> to use to prompt the user for confirmation of the deletion.</param> ///<param name="customConfirmationMessageDelegate">The delegate to use for constructing the confirmation message that will be /// displayed to the user for a particular <see cref="IBusinessObject"/>.</param> public ConfirmingBusinessObjectDeletor(IConfirmer confirmer, Function <IBusinessObject, string> customConfirmationMessageDelegate) : this(confirmer) { CustomConfirmationMessageDelegate = customConfirmationMessageDelegate; }
public TextManagerViewModel(IConfirmer confirmer, IWindowBase window) { _confirmer = confirmer; _window = window; }