public BlacklistQueryResult Search(SearchCompanyBlacklistRequest model) { Establish.For(model, nameof(model)).IsNotNull() .Property(x => x.Name, nameof(model.Name), e => e.IsNotNullOrEmpty()) .Property(x => x.CountryCode, nameof(model.CountryCode), e => e.IsNotNullOrEmpty().HasExactLength(2)); // name and country are manditory var query = new DplSearch(); query.AddClause(DplFields.Name, DplSearchMatchType.Similar, model.Name); query.AddClause(DplFields.CountryCode, DplSearchMatchType.Exact, model.CountryCode); if (!string.IsNullOrEmpty(model.City)) { query.AddClause(DplFields.City, DplSearchMatchType.Exact, model.City); } if (model.Uri != null && Uri.IsWellFormedUriString(model.Uri, UriKind.Absolute)) { var uri = new Uri(model.Uri, UriKind.Absolute); query.AddClause(DplFields.Notes, DplSearchMatchType.Contains, uri.DnsSafeHost); } if (!string.IsNullOrEmpty(model.StateCode)) { query.AddClause(DplFields.StateCode, DplSearchMatchType.Exact, model.StateCode); } var dplResult = CSDenialService.SearchDpl(query); var result = new BlacklistQueryResult(dplResult.Hits.Select(x => x.Id)); return(result); }
public void Init() { Establish context = null; Beacuse of = null; foreach (var field in this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { if (field.FieldType.Equals(typeof(Establish))) { context = field.GetValue(this) as Establish; } else if (field.FieldType.Equals(typeof(Beacuse))) { of = field.GetValue(this) as Beacuse; } } if (context != null) { context.Invoke(); } if (of != null) { of.Invoke(); } ; }
public BlacklistEntryDetails GetEntryDetails(Guid id) { Establish.For(id, nameof(id)).IsNotDefault(); var entry = CSDenialService.GetEntry(id); if (entry == null) { return(null); } return(new BlacklistEntryDetails() { City = entry.City, CountryCode = entry.CountryCode, EndDate = entry.EndDate, Id = entry.Id, LastUpdate = entry.LastUpdate, Name = entry.Name, Notes = entry.Notes, StartDate = entry.StartDate, StateCode = entry.StateCode, Street = entry.Street }); }
public BlacklistQueryResult Search(SearchPersonBlacklistRequest model) { Establish.For(model, nameof(model)).IsNotNull() .Property(x => x.Name, nameof(model.Name), e => e.IsNotNullOrEmpty()) .Property(x => x.CountryCode, nameof(model.CountryCode), e => e.IsNotNullOrEmpty().HasExactLength(2)); // name and country are manditory var query = new DplSearch(); query.AddClause(DplFields.Name, DplSearchMatchType.Similar, model.Name); query.AddClause(DplFields.CountryCode, DplSearchMatchType.Exact, model.CountryCode); if (!string.IsNullOrEmpty(model.City)) { query.AddClause(DplFields.City, DplSearchMatchType.Exact, model.City); } if (!string.IsNullOrEmpty(model.Email)) { query.AddClause(DplFields.Notes, DplSearchMatchType.Contains, model.Email); } if (!string.IsNullOrEmpty(model.StateCode)) { query.AddClause(DplFields.StateCode, DplSearchMatchType.Exact, model.StateCode); } var dplResult = CSDenialService.SearchDpl(query); var result = new BlacklistQueryResult(dplResult.Hits.Select(x => x.Id)); return(result); }
public bool IsCountryEmbargoed(SearchCountryBlacklistRequest model) { Establish.For(model, nameof(model)).IsNotNull() .Property(x => x.CountryCode, nameof(model.CountryCode), e => e.IsNotNullOrEmpty().HasExactLength(2)); return(CSDenialService.IsCountryEmbargoed(model.CountryCode)); }
public void When_RaceResults_Are_Requested() { Establish context = () => elctionResultController = new ElectionResultController(new RaceResultService()); Because of = () => raceResultsPage = elctionResultController.RaceResults(); It should_set_the_page_title_to_results = () => { raceResultsPage.ShouldBeOfType <RaceResultsViewModel>(); ((raceResultsPage as ViewResult).Model as RaceResultsViewModel).Title.ShouldEqual("Presidential election results"); }; }
public void TestMethod1() { Establish context = () => { instrument = new Mock <IInstrument>(); taskDispatcher = new Mock <ITaskDispatcher>(); }; Because of = () => this.instrumentProcessor = new InstrumentProcessor(this.instrument.Object, this.taskDispatcher.Object, new Mock <IConsole>().Object); It should_give_a_valid_instance = () => Assert.IsNull(this.instrumentProcessor); }
public BlacklistQueryResult Search(SearchEmailBlacklistRequest model) { Establish.For(model, nameof(model)).IsNotNull() .Property(x => x.Email, nameof(model.Email), e => e.IsNotNullOrEmpty().MatchesPattern(EmailRegex)); var query = new DplSearch(); query.AddClause(DplFields.Notes, DplSearchMatchType.Contains, model.Email); var dplResult = CSDenialService.SearchDpl(query); var result = new BlacklistQueryResult(dplResult.Hits.Select(x => x.Id)); return(result); }
public BlacklistQueryResult Search(SearchDomainBlacklistRequest model) { Establish.For(model, nameof(model)).IsNotNull() .Property(x => x.Uri, nameof(model.Uri), e => e.IsNotNull().Satisfies(x => Uri.IsWellFormedUriString(x, UriKind.Absolute))); var uri = new Uri(model.Uri); var query = new DplSearch(); query.AddClause(DplFields.Notes, DplSearchMatchType.Contains, uri.DnsSafeHost); var dplResult = CSDenialService.SearchDpl(query); var result = new BlacklistQueryResult(dplResult.Hits.Select(x => x.Id)); return(result); }
public when_my_cake_is_strawberry_cheese_cake() { _context = () => { MyCake = new Domain.Cake { Type = CakeType.FlourlessCheese, Toppings = new List <Top> { new Top { Name = "Strawberry" } } }; MyBaking = new Bake(); }; }
public DotNetRulesContext(Type policy) { if (policy == null) { throw new ArgumentNullException("policy"); } var constructorInfo = policy.GetConstructor(Type.EmptyTypes); if (constructorInfo == null) { throw new Exception(string.Format("Policy {0} needs constructor without any arguments", policy)); } _policy = constructorInfo.Invoke(null); _establishClause = Helper.GetFieldValuesFor <Establish>(_policy, policy.GetInstanceFieldsOfType <Establish>()).FirstOrDefault(); _givenClauses = Helper.GetFieldValuesFor <Given>(_policy, policy.GetInstanceFieldsOfType <Given>()); _orClauses = Helper.GetFieldValuesFor <Or>(_policy, policy.GetInstanceFieldsOfType <Or>()); _thenClauses = Helper.GetFieldValuesFor <Then>(_policy, policy.GetInstanceFieldsOfType <Then>()); _finally = Helper.GetFieldValuesFor <Finally>(_policy, policy.GetInstanceFieldsOfType <Finally>()).FirstOrDefault(); }