public void Not_Throw_If_Alias_Doesnt_Exist_When_Looking_Up() { // arrange var repo = new AliasRepository(); // act // assert repo.Lookup("whatever").Should().BeEmpty(); }
public MailManagementService(IConfiguration configuration, AliasContext context, ILogger <MailboxHandler> logger) { var appSettings = new AppSettings(); configuration.Bind(appSettings); var aliases = new AliasRepository(context); _handler = new MailboxHandler(appSettings.Mailbox, aliases, logger); }
public void Return_True_Only_If_A_Parser_Has_An_Alias() { // arrange var repo = new AliasRepository(); repo.SetAlias("a", "1"); // act // assert repo.HasAlias("a").Should().BeTrue(); repo.HasAlias("b").Should().BeFalse(); }
public void Return_The_Most_Recently_Set_Alias() { // arrange var repo = new AliasRepository(); // act repo.SetAlias("a", "A"); repo.SetAlias("a", "1"); // assert repo.GetAlias("a").Should().Be("1"); }
public void Return_All_Commands_That_Match_Alias() { // arrange var repo = new AliasRepository(); // act repo.SetAlias("1", "a"); repo.SetAlias("2", "a"); // assert repo.Lookup("a").Should().BeEquivalentTo("1 2".Split(' ')); }
public object Get(FollowShortUrlRequest request) { if (!AliasRepository.ContainsKey(request.Key)) { throw HttpError.NotFound("Short URL '{0}' does not exist".Fmt(request.Key)); } var destination = AliasRepository.GetValue(request.Key); return(new HttpResult { StatusCode = HttpStatusCode.Redirect, Headers = { { HttpHeaders.Location, destination } } }); }
public void Setup() { var options = new DbContextOptionsBuilder <FieldAgentContext>() .UseInMemoryDatabase("testDatabase") .Options; db = new FieldAgentContext(options); db.Database.EnsureDeleted(); db.Database.EnsureCreated(); db.SaveChanges(); aliasRepo = new AliasRepository(db); }
/// <summary> /// Configures the api. /// </summary> /// <param name="modelCache">The optional model cache</param> /// <param name="imageProcessor">The optional image processor</param> private void Setup(IContentServiceFactory factory, ICache modelCache = null, IImageProcessor imageProcessor = null) { cache = modelCache; var cacheLevel = (int)App.CacheLevel; Aliases = new AliasRepository(this, db, cacheLevel > 2 ? cache : null); Archives = new ArchiveRepository(this, db); Categories = new CategoryRepository(this, db, cacheLevel > 2 ? cache : null); Media = new MediaRepository(this, db, storage, cacheLevel > 2 ? cache : null, imageProcessor); Pages = new PageRepository(this, db, factory, cacheLevel > 2 ? cache : null); PageTypes = new PageTypeRepository(db, cacheLevel > 1 ? cache : null); Params = new ParamRepository(db, cacheLevel > 0 ? cache : null); Posts = new PostRepository(this, db, factory, cacheLevel > 2 ? cache : null); PostTypes = new PostTypeRepository(db, cacheLevel > 1 ? cache : null); Sites = new SiteRepository(this, db, cacheLevel > 0 ? cache : null); Tags = new TagRepository(db, cacheLevel > 2 ? cache : null); }
public UpdateAAliasCV( ILogger logger, AliasRepository repository ) : base(logger) { // Conditions Condition.Requires(repository, nameof(repository)).IsNotNull(); this.repository = repository; // Validation rules RuleFor(x => x.Version) .NotNull() .NotEqual(0) .WithSeverity(Severity.Error); RuleFor(x => x.UniqueId.Value) .NotNull() .NotEqual(new Guid()); RuleFor(x => x.TenantUniqueId) .NotNull() .NotEqual(new Guid()); RuleFor(x => x.UserUniqueId) .NotNull() .NotEqual(new Guid()); RuleFor(x => x.CorrelationUniqueId) .NotNull() .NotEqual(new Guid()); // Add for each custom property rules to validate RuleFor(x => x.Text) .NotNull(); RuleFor(x => x.FrameworkUniqueId) .NotNull(); RuleFor(x => x.CategoryUniqueId) .NotNull(); }
public ArtistResponse Search(string criteria, int pageNumber, int pageSize) { //Fetch the unfiltered list from the repository layer so obtain the count of the results var artistResults = ArtistRepository.SearchArtist(criteria); //Filtered and paginated by LINQ var artistListResults = artistResults.OrderBy(a => a.Lastname).Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList(); //Initialize the response to be returned var artistResponse = new ArtistResponse { ArtistCollectionResponse = new List <ArtistCollectionResponse>() }; //Build the response to be returned foreach (var artistResult in artistListResults) { artistResponse.ArtistCollectionResponse.Add(new ArtistCollectionResponse { Name = string.Concat(artistResult.Firstname.Trim(), " ", artistResult.Lastname.Trim()).Trim(), Country = artistResult.CountryIso, Alias = new List <string>(AliasRepository.GetByArtistId(artistResult.Id).Select(a => a.Text).ToList()) }); } //Assign proper values to the 'page' properties artistResponse.NumberOfSearchResults = artistResults.Count(); //Round up the number to prevent decimal. //Example if there are 5 item and 2 per page, there should be 3 pages. so that 2.5 pages should be rounded up to 3 pages var numberOfpages = (int)Math.Ceiling((double)artistResponse.NumberOfSearchResults / pageSize); artistResponse.Page = pageNumber.ToString(); artistResponse.PageSize = pageSize.ToString(); artistResponse.NumberOfPages = numberOfpages.ToString(); return(artistResponse); }
public UpdateAAliasCH(AliasRepository repository) : base(repository) { this._repository = repository; }