public void Test_AttachmentStatusSpecification_SatisfyEntityFrom() { var specification = new AttachmentStatusSpecification(AttachmentStatus.Published); var result = specification.SatisfyEntityFrom(this.Values); Assert.AreEqual(AttachmentStatus.Published, result.Status); }
public void Test_AttachmentStatusSpecification_SatisfyEntitiesFrom() { var specification = new AttachmentStatusSpecification(AttachmentStatus.Published); var results = specification.SatisfyEntitiesFrom(this.Values); Assert.AreEqual(1, results.Count()); }
/// <summary> /// Initializes a new instance of the <see cref="AttachmentQuery"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="status">The status.</param> /// <param name="sort">The sort.</param> /// <param name="order">The order.</param> /// <param name="page">The page.</param> public AttachmentQuery(string type, string status, SortAttachment sort, SortOrder order, int? page) { IAttachmentSpecification specification = null; if (!string.IsNullOrEmpty(type)) { specification = new AttachmentFileTypeSpecification(type); } if (!string.IsNullOrEmpty(status)) { if (specification == null) { specification = new AttachmentStatusSpecification(status.AsEnum<AttachmentStatus>()); } else { var spec = new AndSpecification<Attachment>( specification, new AttachmentStatusSpecification(status.AsEnum<AttachmentStatus>()) ); specification = spec as IAttachmentSpecification; } } if (specification == null) { specification = new AttachmentSpecification(); } specification.Page = page; specification.Limit = Setting.AttachmentPageLimit.Value; specification.Sort = sort; specification.Order = order; this.Specification = specification; }