public async Task ItReturnsAllSpeakerDescending() { // Arrange var spec = new SpeakerSpecification(1, 1, nameof(Direction.Desc)); // Act var speakers = (List <Speaker>) await Repository.List(spec); // Assert Assert.IsAssignableFrom <IEnumerable <Speaker> >(speakers); }
public void WhenSpeakerNotFoundWithId_ThenNull() { // Arrange var badSpeakerId = new Guid("172B6257-582D-4453-A13F-41C6CBE4CAB2"); var spec = new SpeakerSpecification(badSpeakerId); // Act var result = spec.Evaluate(GetTestCollection()).SingleOrDefault(); // Assert Assert.Null(result); }
public void WhenSpeakerFoundWithId_ThenSpeakerReturned() { // Arrange var spec = new SpeakerSpecification(_id); // Act var result = spec.Evaluate(GetTestCollection()).Single(); // Assert Assert.NotNull(result); Assert.Equal(_id, result.Id); }
public void WhenSpeakerFoundWithSlug_ThenSpeakerReturned() { // Arrange var spec = new SpeakerSpecification(_slug); // Act var result = spec.Evaluate(GetTestCollection()).Single(); // Assert spec.AsNoTracking.Should().Be(true); Assert.NotNull(result); Assert.Equal(_slug, result.Slug); }
public async Task <SpeakersResult> GetAll(int pageIndex, int itemsPage, string?direction) { var spec = new SpeakerSpecification(itemsPage * pageIndex, itemsPage, direction); var speakers = await _repository.List(spec); var total = await _repository.Count <Speaker>(); return(new SpeakersResult { Speakers = speakers.Select(x => new SpeakersResult.Speaker { Id = x.Id, Location = x.Location, Name = x.Name, Slug = x.Slug, Description = x.Description, }).ToList(), PaginationInfo = new PaginationInfo(total, speakers.Count, pageIndex, int.Parse(Math.Ceiling((decimal)total / itemsPage) .ToString(CultureInfo.InvariantCulture))) }); }