public void WhenConferenceNotFoundWithId_ThenNull()
    {
        // Arrange
        var badConferenceId = new Guid("172B6257-582D-4453-A13F-41C6CBE4CAB2");
        var spec            = new ConferenceSpecification(badConferenceId);

        // Act
        var result = spec.Evaluate(GetTestCollection()).SingleOrDefault();

        // Assert
        Assert.Null(result);
    }
    public void WhenConferenceFoundWithId_ThenConferenceReturned()
    {
        // Arrange
        var spec = new ConferenceSpecification(_id);

        // Act
        var result = spec.Evaluate(GetTestCollection()).Single();

        // Assert
        Assert.NotNull(result);
        Assert.Equal(_id, result.Id);
    }
    public void WhenConferenceFoundWithSlug_ThenConferenceReturned()
    {
        // Arrange
        var spec = new ConferenceSpecification(_slug);

        // Act
        var result = spec.Evaluate(GetTestCollection()).Single();

        // Assert
        spec.AsNoTracking.Should().Be(true);
        Assert.NotNull(result);
        Assert.Equal(_slug, result.Slug);
    }
Example #4
0
        public async Task <ConferencesResult> GetAll(int pageIndex, int itemsPage, string?direction)
        {
            var spec = new ConferenceSpecification(itemsPage * pageIndex, itemsPage, direction);

            var conferences = await _repository.List(spec);

            var total = await _repository.Count <Conference>();

            return(new ConferencesResult
            {
                Conferences = conferences.Select(x => new ConferencesResult.Conference
                {
                    Id = x.Id,
                    Location = x.Location,
                    Name = x.Name,
                    Slug = x.Slug,
                    Description = x.Description,
                }).ToList().AsReadOnly(),
                PaginationInfo = new PaginationInfo(total, conferences.Count, pageIndex, int.Parse(Math.Ceiling((decimal)total / itemsPage)
                                                                                                   .ToString(CultureInfo.InvariantCulture)))
            });
        }