public void Name_spec_should_match_on_partial_text() { var specification = new NameSpecification("node"); var matches = specification.Matches(new TestTreeNode("id", "some node text")); Assert.IsTrue(matches); }
public void Namespace_spec_should_not_match_if_namespace_is_different() { var specification = new NameSpecification("wahwahwah"); var matches = specification.Matches(new TestTreeNode("id", "some node text")); Assert.IsFalse(matches); }
public void Name_spec_should_match_on_node_text() { const string text = "some node text"; var specification = new NameSpecification(text); var matches = specification.Matches(new TestTreeNode("id", text)); Assert.IsTrue(matches); }
public Task <IResponseContainer> IsSatisfiedBy(Group entity) { var result = new ResponseContainer(); if (capacityInAmps <= 0) { result.AddErrorMessage($"Capacity has to be greater than 0."); } var nameSpecificationResponseContainer = new NameSpecification().IsSatisfiedBy(name).Result; result.JoinWith(nameSpecificationResponseContainer); return(Task.FromResult(result.AsInterface())); }
private ISpecification <Project> BuildProjectSpecification(IEnumerable <FieldFilter> fieldFilters) { ISpecification <Project> spec = null; if (fieldFilters != null && fieldFilters.Any()) { foreach (var fieldFilter in fieldFilters) { ISpecification <Project> temp = null; switch (fieldFilter.Field) { //我的项目 case "RelationType": if (string.IsNullOrWhiteSpace(fieldFilter.Value)) { //如果非管理员级别,增加默认的过滤条件,只能查看与自己相关的项目 if (!UserInfo.RightDetail.EnableViewList) { temp = new OrSpecification <Project>(new CreatorIdSpecification(UserInfo.UserId), new ManagerIdsSpecification(UserInfo.UserId)); temp = new OrSpecification <Project>(temp, new ParticipantIdsSpecification(UserInfo.UserId)); } } else { switch (fieldFilter.Value) { case "0": temp = new CreatorIdSpecification(UserInfo.UserId); break; case "1": temp = new ManagerIdsSpecification(UserInfo.UserId); break; case "2": temp = new OrSpecification <Project>(new CreatorIdSpecification(UserInfo.UserId), new ManagerIdsSpecification(UserInfo.UserId)); temp = new OrSpecification <Project>(temp, new ParticipantIdsSpecification(UserInfo.UserId)); //temp = new OrSpecification<Project>(new ManagerIdsSpecification(UserInfo.UserId), new ParticipantIdsSpecification(UserInfo.UserId)); break; } } break; case "Status": if (!string.IsNullOrWhiteSpace(fieldFilter.Value)) { temp = new StatusSpecification(Int32.Parse(fieldFilter.Value)); } break; case "Type": if (!string.IsNullOrWhiteSpace(fieldFilter.Value)) { temp = new TypeSpecification(Int32.Parse(fieldFilter.Value)); } break; case "ProjectName": if (!string.IsNullOrWhiteSpace(fieldFilter.Value)) { temp = new NameSpecification(fieldFilter.Value); } break; case "ManagerId": if (!string.IsNullOrWhiteSpace(fieldFilter.Value)) { temp = new ManagerIdsSpecification(fieldFilter.Value); } break; case "ParticipantId": if (!string.IsNullOrWhiteSpace(fieldFilter.Value)) { temp = new ParticipantIdsSpecification(fieldFilter.Value); } break; case "StartTime": { DateTime?min = null; DateTime?max = null; if (TryGetDateTimeSpanValue(fieldFilter.Value, ref min, ref max)) { temp = new StartTimeSpecification(min, max); } } break; case "Deadline": { DateTime?min = null; DateTime?max = null; if (TryGetDateTimeSpanValue(fieldFilter.Value, ref min, ref max)) { temp = new DeadlineSpecification(min, max); } } break; } if (temp != null) { spec = spec == null ? temp : new AndSpecification <Project>(spec, temp); } } } return(spec); }