protected override IEnumerable <INotificationMessage> PerformGetAll(params Guid[] keys) { var dtos = new List <NotificationMessageDto>(); if (keys.Any()) { // This is to get around the WhereIn max limit of 2100 parameters and to help with performance of each WhereIn query var keyLists = keys.Split(400).ToList(); // Loop the split keys and get them foreach (var keyList in keyLists) { dtos.AddRange(Database.Fetch <NotificationMessageDto>(GetBaseQuery(false).WhereIn <NotificationMessageDto>(x => x.Key, keyList, SqlSyntax))); } } else { dtos = Database.Fetch <NotificationMessageDto>(GetBaseQuery(false)); } var factory = new NotificationMessageFactory(); foreach (var dto in dtos) { yield return(factory.BuildEntity(dto)); } }
public void ShouldThrowArgumentNullException() { Assert.Multiple(() => { Assert.That(() => NotificationMessageFactory.GetToastXml(null, new Uri("http://localhost/")), Throws.ArgumentNullException); Assert.That(() => NotificationMessageFactory.GetToastXml("message", null), Throws.ArgumentNullException); }); }
public void ShouldNotThrowException() { var notifier = ToastNotificationManager.CreateToastNotifier("Website Poller"); var wrapper = new ToastNotifierWrapper(notifier); var toastXml = NotificationMessageFactory.GetToastXml("foo", new Uri("http://localhost/")); var toast = new ToastNotification(toastXml); Assert.That(() => wrapper.Show(toast), Throws.Nothing); notifier.Hide(toast); }
protected override void PersistUpdatedItem(INotificationMessage entity) { ((Entity)entity).UpdatingEntity(); var factory = new NotificationMessageFactory(); var dto = factory.BuildDto(entity); Database.Update(dto); entity.ResetDirtyProperties(); }
public void ShouldProduceCorrectMessage() { var assemblyPath = An.AssemblyPath(); var path = Path.Combine(assemblyPath, "Workflow", "toast.xml"); var content = File.ReadAllText(path); var result = NotificationMessageFactory.GetToastXml("message", new Uri("http://localhost/")); Assert.That(result, Is.Not.Null); Assert.That(result.GetXml(), Is.EqualTo(content)); }
/// <summary> /// Updates an existing item in the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistUpdatedItem(INotificationMessage entity) { ((Entity)entity).UpdatingEntity(); var factory = new NotificationMessageFactory(); var dto = factory.BuildDto(entity); Database.Update(dto); entity.ResetDirtyProperties(); // RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey<INotificationMethod>(entity.MethodKey)); }
protected override void PersistNewItem(INotificationMessage entity) { ((Entity)entity).AddingEntity(); var factory = new NotificationMessageFactory(); var dto = factory.BuildDto(entity); Database.Insert(dto); entity.Key = dto.Key; entity.ResetDirtyProperties(); }
protected override INotificationMessage PerformGet(Guid key) { var sql = GetBaseQuery(false) .Where(GetBaseWhereClause(), new { Key = key }); var dto = Database.Fetch <NotificationMessageDto>(sql).FirstOrDefault(); if (dto == null) { return(null); } var factory = new NotificationMessageFactory(); return(factory.BuildEntity(dto)); }
protected override IEnumerable <INotificationMessage> PerformGetAll(params Guid[] keys) { if (keys.Any()) { foreach (var key in keys) { yield return(Get(key)); } } else { var factory = new NotificationMessageFactory(); var dtos = Database.Fetch <NotificationMessageDto>(GetBaseQuery(false)); foreach (var dto in dtos) { yield return(factory.BuildEntity(dto)); } } }