コード例 #1
0
        public async Task Should_Only_Return_Online_Events()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new EventServiceFactory().Create(context);

                var result = await service.Search("",
                                                  new List <SearchFilter>() { new() { Key = SearchParam.IsOnline, Value = "true" } }, new Guid());
コード例 #2
0
        public async Task Null_Keyword_Should_Return_All()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new EventServiceFactory().Create(context);

                var result = await service.Search(null, new List <SearchFilter>(), new Guid());

                result.Should().NotBeNull();
                result.Count.Should().BeGreaterThan(2);
            }
        }
コード例 #3
0
        public async Task Should_Search_By_Keyword()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new EventServiceFactory().Create(context);

                var result = await service.Search("Test", new List <SearchFilter>(), new Guid());

                result.Count().Should().BeGreaterThan(0);
                result.ForEach(r => r.Name.Should().Contain("Test"));
            }
        }
コード例 #4
0
        public async Task Should_Limit_Results_To_50()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new EventServiceFactory().Create(context);

                await context.Events.AddRangeAsync(EventData.FakeEvent.Generate(100).ToList());

                await context.SaveChangesAsync();

                var result = await service.Search("", new List <SearchFilter>(), new Guid());

                result.Should().NotBeNull();
                result.Count().Should().Be(50);
            }
        }
コード例 #5
0
        public async Task Should_Search_By_Category()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new EventServiceFactory().Create(context);

                var categoryId = context.Categories.First().Id;

                var searchFilters = new List <SearchFilter>()
                {
                    new()
                    {
                        Key   = SearchParam.Category,
                        Value = categoryId.ToString() // Music category
                    }
                };
                var result = await service.Search("", searchFilters, new Guid());

                result.Count().Should().Be(1);
            }
        }