/// <summary> /// Saves the <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous"> /// The anonymous customer /// </param> /// <param name="raiseEvents"> /// TOptional boolean indicating whether or not to raise events /// </param> public void Save(IAnonymousCustomer anonymous, bool raiseEvents = true) { if (raiseEvents) { if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IAnonymousCustomer>(anonymous), this)) { return; } } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAnonymousCustomerRepository(uow)) { repository.AddOrUpdate(anonymous); uow.Commit(); } } if (raiseEvents) { Saved.RaiseEvent(new SaveEventArgs <IAnonymousCustomer>(anonymous), this); } }
public static IAnonymousCustomer MockSavedWithKey(this IAnonymousCustomer entity, Guid key) { ((Entity)entity).UpdatingEntity(); entity.Key = key; entity.ResetDirtyProperties(); return(entity); }
/// <summary> /// Deletes a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous">The <see cref="IAnonymousCustomer"/> to delete</param> public void Delete(IAnonymousCustomer anonymous) { using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateAnonymousCustomerRepository(uow)) { repository.Delete(anonymous); uow.Commit(); } } }
public static IItemCache AnonymousBasket(IAnonymousCustomer anonymous, ItemCacheType itemCacheType) { var itemCache = new ItemCache(anonymous.Key, itemCacheType) { Key = Guid.NewGuid(), CreateDate = DateTime.Now, UpdateDate = DateTime.Now }; itemCache.ResetDirtyProperties(); return itemCache; }
public static IItemCache AnonymousBasket(IAnonymousCustomer anonymous, ItemCacheType itemCacheType) { var itemCache = new ItemCache(anonymous.Key, itemCacheType) { Key = Guid.NewGuid(), CreateDate = DateTime.Now, UpdateDate = DateTime.Now }; itemCache.ResetDirtyProperties(); return(itemCache); }
public override void FixtureSetup() { base.FixtureSetup(); _itemCacheService = new ItemCacheService(new MockUnitOfWorkProvider(), new RepositoryFactory(), new Mock <ILogger>().Object); Before = null; After = null; _anonymous = MockAnonymousCustomerDataMaker .AnonymousCustomerForInserting() .MockSavedWithKey(Guid.NewGuid()); ItemCacheService.Saving += delegate(IItemCacheService sender, SaveEventArgs <IItemCache> args) { BeforeTriggered = true; Before = args.SavedEntities.FirstOrDefault(); }; ItemCacheService.Saved += delegate(IItemCacheService sender, SaveEventArgs <IItemCache> args) { AfterTriggered = true; After = args.SavedEntities.FirstOrDefault(); }; ItemCacheService.Created += delegate(IItemCacheService sender, Core.Events.NewEventArgs <IItemCache> args) { AfterTriggered = true; After = args.Entity; }; ItemCacheService.Deleting += delegate(IItemCacheService sender, DeleteEventArgs <IItemCache> args) { BeforeTriggered = true; Before = args.DeletedEntities.FirstOrDefault(); }; ItemCacheService.Deleted += delegate(IItemCacheService sender, DeleteEventArgs <IItemCache> args) { AfterTriggered = true; After = args.DeletedEntities.FirstOrDefault(); }; // General tests MockDatabaseUnitOfWork.Committed += delegate(object sender) { CommitCalled = true; }; }
/// <summary> /// Deletes the <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous"> /// The anonymous customer /// </param> public void Delete(IAnonymousCustomer anonymous) { if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IAnonymousCustomer>(anonymous), this)) { return; } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAnonymousCustomerRepository(uow)) { repository.Delete(anonymous); uow.Commit(); } } Deleted.RaiseEvent(new DeleteEventArgs <IAnonymousCustomer>(anonymous), this); }
/// <summary> /// Deletes the <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous"> /// The anonymous customer /// </param> public void Delete(IAnonymousCustomer anonymous) { if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<IAnonymousCustomer>(anonymous), this)) return; using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateAnonymousCustomerRepository(uow)) { repository.Delete(anonymous); uow.Commit(); } } Deleted.RaiseEvent(new DeleteEventArgs<IAnonymousCustomer>(anonymous), this); }
protected override void Initialize() { _invoiceService = new InvoiceService(new MockUnitOfWorkProvider(), new RepositoryFactory()); _invoice = _invoiceService.CreateInvoice(_customer, _invoiceStatus, "test111", "name", "address1", "address2", "city", "state", "98225", "US", "*****@*****.**", string.Empty, string.Empty); Before = null; After = null; _beforeInvoice = null; _afterInvoice = null; _statusBefore = false; _statusAfter = false; _customer = MockCustomerDataMaker.CustomerForInserting().MockSavedWithKey(111); _invoiceStatus = MockInvoiceStatusDataMaker.InvoiceStatusUnpaidMock(); _anonymous = MockAnonymousCustomerDataMaker.AnonymousCustomerForInserting().MockSavedWithKey(Guid.NewGuid()); InvoiceService.Saving += delegate(IInvoiceService sender, SaveEventArgs <IInvoice> args) { BeforeTriggered = true; Before = args.SavedEntities.FirstOrDefault(); }; InvoiceService.Saved += delegate(IInvoiceService sender, SaveEventArgs <IInvoice> args) { AfterTriggered = true; After = args.SavedEntities.FirstOrDefault(); }; InvoiceService.Created += delegate(IInvoiceService sender, Core.Events.NewEventArgs <IInvoice> args) { AfterTriggered = true; After = args.Entity; }; InvoiceService.Deleting += delegate(IInvoiceService sender, DeleteEventArgs <IInvoice> args) { BeforeTriggered = true; Before = args.DeletedEntities.FirstOrDefault(); }; InvoiceService.Deleted += delegate(IInvoiceService sender, DeleteEventArgs <IInvoice> args) { AfterTriggered = true; After = args.DeletedEntities.FirstOrDefault(); }; InvoiceService.StatusChanging += delegate(IInvoiceService sender, StatusChangeEventArgs <IInvoice> args) { _statusBefore = true; _beforeInvoice = args.StatusChangedEntities; }; InvoiceService.StatusChanged += delegate(IInvoiceService sender, StatusChangeEventArgs <IInvoice> args) { _statusAfter = true; _afterInvoice = args.StatusChangedEntities; }; // General tests MockDatabaseUnitOfWork.Committed += delegate { CommitCalled = true; }; }
/// <summary> /// Deletes a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous">The <see cref="IAnonymousCustomer"/> to delete</param> public void Delete(IAnonymousCustomer anonymous) { _anonymousCustomerService.Delete(anonymous); }
/// <summary> /// Saves a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous"> /// The <see cref="IAnonymousCustomer"/> to save /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> public void Save(IAnonymousCustomer anonymous, bool raiseEvents = true) { _anonymousCustomerService.Save(anonymous, raiseEvents); }
public override void FixtureSetup() { base.FixtureSetup(); //IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger var repositoryFactory = new Mock <RepositoryFactory>( false, new NullCacheProvider(), new NullCacheProvider(), Logger.CreateWithDefaultLog4NetConfiguration(), SqlSyntaxProvider); //bool disableAllCache, //IRuntimeCacheProvider nullCacheProvider, //IRuntimeCacheProvider runtimeCacheProvider, //ILogger logger, //ISqlSyntaxProvider sqlSyntaxProvider var uow = new MockUnitOfWorkProvider(); _itemCacheService = new ItemCacheService(uow, repositoryFactory.Object, new Mock <ILogger>().Object); Before = null; After = null; _anonymous = MockAnonymousCustomerDataMaker .AnonymousCustomerForInserting() .MockSavedWithKey(Guid.NewGuid()); ItemCacheService.Saving += delegate(IItemCacheService sender, SaveEventArgs <IItemCache> args) { BeforeTriggered = true; Before = args.SavedEntities.FirstOrDefault(); }; ItemCacheService.Saved += delegate(IItemCacheService sender, SaveEventArgs <IItemCache> args) { AfterTriggered = true; After = args.SavedEntities.FirstOrDefault(); }; ItemCacheService.Created += delegate(IItemCacheService sender, Core.Events.NewEventArgs <IItemCache> args) { AfterTriggered = true; After = args.Entity; }; ItemCacheService.Deleting += delegate(IItemCacheService sender, DeleteEventArgs <IItemCache> args) { BeforeTriggered = true; Before = args.DeletedEntities.FirstOrDefault(); }; ItemCacheService.Deleted += delegate(IItemCacheService sender, DeleteEventArgs <IItemCache> args) { AfterTriggered = true; After = args.DeletedEntities.FirstOrDefault(); }; // General tests MockDatabaseUnitOfWork.Committed += delegate(object sender) { CommitCalled = true; }; }
/// <summary> /// Deletes a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous">The <see cref="IAnonymousCustomer"/> to delete</param> public void Delete(IAnonymousCustomer anonymous) { _anonymousCustomerService.Delete(anonymous); }
/// <summary> /// Saves a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous">The <see cref="IAnonymousCustomer"/> to save</param> public void Save(IAnonymousCustomer anonymous) { _anonymousCustomerService.Save(anonymous); }
/// <summary> /// Saves a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous">The <see cref="IAnonymousCustomer"/> to save</param> public void Save(IAnonymousCustomer anonymous) { using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateAnonymousCustomerRepository(uow)) { repository.AddOrUpdate(anonymous); uow.Commit(); } } }
/// <summary> /// Saves a single <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous">The <see cref="IAnonymousCustomer"/> to save</param> public void Save(IAnonymousCustomer anonymous) { _anonymousCustomerService.Save(anonymous); }
public void Initialize() { PreTestDataWorker.DeleteAllItemCaches(); _itemCacheService = PreTestDataWorker.ItemCacheService; _anonymous = PreTestDataWorker.MakeExistingAnonymousCustomer(); }
/// <summary> /// Saves the <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymous"> /// The anonymous customer /// </param> /// <param name="raiseEvents"> /// TOptional boolean indicating whether or not to raise events /// </param> public void Save(IAnonymousCustomer anonymous, bool raiseEvents = true) { if (raiseEvents) if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IAnonymousCustomer>(anonymous), this)) { return; } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAnonymousCustomerRepository(uow)) { repository.AddOrUpdate(anonymous); uow.Commit(); } } if (raiseEvents) Saved.RaiseEvent(new SaveEventArgs<IAnonymousCustomer>(anonymous), this); }
public void Initialize() { PreTestDataWorker.DeleteAllItemCaches(); _itemCacheService = PreTestDataWorker.ItemCacheService; _anonymous = PreTestDataWorker.MakeExistingAnonymousCustomer(); }