Esempio n. 1
0
            protected override void Given()
            {
                var postOne       = Mock.Of <IPostSummary>();
                var postTwo       = Mock.Of <IPostSummary>();
                var postThree     = Mock.Of <IPostSummary>();
                var postSummaries =
                    new List <IPostSummary>
                {
                    postOne,
                    postTwo,
                    postThree
                };

                _postSummaryRepositoryMock = new Mock <IPostSummaryRepository>();
                _postSummaryRepositoryMock
                .Setup(x => x.GetPostSummaries())
                .ReturnsAsync(postSummaries);
                var postSummaryRepository = _postSummaryRepositoryMock.Object;

                _postRepositoryMock = new Mock <IPostRepository>();
                var postRepository = _postRepositoryMock.Object;

                _postFilter = new PostFilterBuilder().Build();

                _sut = new BlogQueryService(postSummaryRepository, postRepository);

                _expectedPosts = postSummaries;
            }
Esempio n. 2
0
 /// <summary>
 /// Add a filter for this target.
 /// </summary>
 /// <param name="filter">Filters are used to validate if an entry can be written to a target or not.</param>
 public void AddFilter(IPostFilter filter)
 {
     if (filter == null)
     {
         throw new ArgumentNullException("filter");
     }
     _filters.AddLast(filter);
 }
Esempio n. 3
0
        //------------------------------------------------------------------------
        public void Init(CODEQBase odeqBase)
        {
            m_odeqTable  = odeqBase;
            m_postFilter = m_odeqTable != null ? m_odeqTable.PostFilter : null;
            CDefPostFilter def = m_postFilter != null?CAllocateurPostFilter.GetDef(m_postFilter.GetType()) : c_defNull;

            m_cmbTypePostFilter.SelectedItem = def;
            UpdatePanelPostFilter();
        }
Esempio n. 4
0
        //--------------------------------------------------------------------------------------
        public void Init(CODEQBase odeqBase, IPostFilter postFilter)
        {
            CPostFilterFromQueryTable postFromQuery = postFilter as CPostFilterFromQueryTable;

            if (postFromQuery == null)
            {
                postFromQuery = new CPostFilterFromQueryTable();
            }
            Init(odeqBase, postFromQuery, odeqBase.Query);
        }
Esempio n. 5
0
        //----------------------------------------------------------------
        public static IPostFilter GetPostFilter(string strId)
        {
            CDefPostFilter def = GetDef(strId);

            if (def != null)
            {
                IPostFilter filter = Activator.CreateInstance(def.TypePostFilter, new object[0]) as IPostFilter;
                return(filter);
            }
            return(null);
        }
        public static IPostFilter CreatePostFilter(string i_Kind, string i_Data)
        {
            ConstructorInfo constructorInfo = sr_FactoryMapping[i_Kind].GetConstructor(new[] { typeof(string) });
            IPostFilter     result          = null;

            if (constructorInfo != null)
            {
                result = constructorInfo.Invoke(new object[] { i_Data }) as IPostFilter;
            }

            return(result);
        }
Esempio n. 7
0
        public async Task <IEnumerable <IPostSummary> > GetPostSummaries(IPostFilter postFilter)
        {
            var allPostMetadata = await _postSummaryRepository.GetPostSummaries();

            var query = allPostMetadata.AsQueryable();

            var filterTag = postFilter.Tag;

            if (!string.IsNullOrWhiteSpace(filterTag))
            {
                query = query.Where(x => x.Tags.Contains(filterTag, StringComparer.InvariantCultureIgnoreCase));
            }

            var filterAuthor = postFilter.Author;

            if (!string.IsNullOrWhiteSpace(filterAuthor))
            {
                query = query.Where(x => x.Author.Equals(filterAuthor, StringComparison.InvariantCultureIgnoreCase));
            }

            var filterYear = postFilter.Year;

            if (filterYear.HasValue)
            {
                query = query.Where(x => x.PublishedOn.Year == filterYear.Value);
            }

            var filterMonth = postFilter.Month;

            if (filterMonth.HasValue)
            {
                query = query.Where(x => x.PublishedOn.Month == filterMonth.Value);
            }

            var filterLanguageCode = postFilter.LanguageCode;

            if (!string.IsNullOrWhiteSpace(filterLanguageCode))
            {
                query = query.Where(x => x.LanguageCode.Equals(filterLanguageCode, StringComparison.InvariantCultureIgnoreCase));
            }

            var filterIncludesDraft = postFilter.IncludesDraft;

            query = query.Where(x => x.IsDraft == filterIncludesDraft);

            var postSummaries = query.ToList();

            return(postSummaries);
        }
        private void checkedListBoxFilterFilters_ItemCheck(object i_Sender, ItemCheckEventArgs i_Args)
        {
            IPostFilter filter = (IPostFilter)postFiltersBindingSource.Current;

            switch (i_Args.NewValue)
            {
            case CheckState.Unchecked:
                filter.Enabled = false;
                break;

            case CheckState.Checked:
                filter.Enabled = true;
                break;
            }
        }
Esempio n. 9
0
        //------------------------------------------------------------------------
        private void m_cmbTypePostFilter_SelectionChangeCommitted(object sender, EventArgs e)
        {
            CDefPostFilter def = m_cmbTypePostFilter.SelectedValue as CDefPostFilter;

            if (def != null && def.TypePostFilter != null)
            {
                if (m_postFilter == null || m_postFilter.GetType() != def.TypePostFilter)
                {
                    m_postFilter = Activator.CreateInstance(def.TypePostFilter, new object[0]) as IPostFilter;
                    UpdatePanelPostFilter();
                }
            }
            else
            {
                m_postFilter = null;
                UpdatePanelPostFilter();
            }
        }
        private void buttonAddFilter_Click(object i_Sender, EventArgs i_Args)
        {
            if (textBoxAddFilter.Text.Length > 0)
            {
                IPostFilter postFilter = PostFilterFactory.CreatePostFilter(comboBoxFilterKind.Text, textBoxAddFilter.Text);
                if (postFilter is PostFilterGroup)
                {
                    FormEditFilterGroup form = new FormEditFilterGroup();
                    form.FilterGroup = postFilter as PostFilterGroup;
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                    {
                        postFiltersBindingSource.Add(postFilter);
                    }

                    textBoxAddFilter.Text = string.Empty;
                }

                postFiltersBindingSource.Add(postFilter);
                textBoxAddFilter.Text = string.Empty;
            }
        }
            protected override void Given()
            {
                var serviceProvider =
                    new ServiceCollection()
                    .AddEasyContent(
                        sp => new PostOptions(),
                        sp => new FileProviderOptions())
                    .OverrideWith(
                        serviceCollection =>
                {
                    serviceCollection.Replace(ServiceDescriptor.Singleton(typeof(IFileProviderConfiguration), typeof(TestFileProviderConfiguration)));
                    serviceCollection.Replace(ServiceDescriptor.Singleton(typeof(IPostConfiguration), typeof(TestPostConfiguration)));
                    return(serviceCollection);
                })
                    .BuildServiceProvider();

                _postFilter =
                    new PostFilterBuilder()
                    .Build();

                _sut = serviceProvider.GetService <IBlogQueryService>();
            }
Esempio n. 12
0
 /// <summary>
 /// Add a filter for this target.
 /// </summary>
 /// <param name="filter">Filters are used to validate if an entry can be written to a target or not.</param>
 public void AddFilter(IPostFilter filter)
 {
     _filters.Add(filter);
 }
Esempio n. 13
0
 /// <summary>
 /// Add a filter for this target.
 /// </summary>
 /// <param name="filter">Filters are used to validate if an entry can be written to a target or not.</param>
 public void AddFilter(IPostFilter filter)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// Add a filter for this target.
 /// </summary>
 /// <param name="filter">Filters are used to validate if an entry can be written to a target or not.</param>
 public void AddFilter(IPostFilter filter)
 {
     if (filter == null) throw new ArgumentNullException("filter");
     _filters.AddLast(filter);
 }
 public void RemovePostFilter(IPostFilter i_PostFilter)
 {
     r_PostFilters.Remove(i_PostFilter);
 }
 public void AddPostFilter(IPostFilter i_PostFilter)
 {
     r_PostFilters.Add(i_PostFilter);
 }
Esempio n. 17
0
 public void AddFilter(IPostFilter filter)
 {
     Filters.Add(filter);
 }
Esempio n. 18
0
 /// <summary>
 /// Add a filter for this target.
 /// </summary>
 /// <param name="filter">Filters are used to validate if an entry can be written to a target or not.</param>
 public void AddFilter(IPostFilter filter)
 {
     Contract.Requires(filter != null);
 }
 public void AddPostFilter(IPostFilter i_PostFilter)
 {
     r_PostFilters.Add(i_PostFilter);
 }
Esempio n. 20
0
 /// <summary>
 /// Add a filter for this target.
 /// </summary>
 /// <param name="filter">Filters are used to validate if an entry can be written to a target or not.</param>
 public void AddFilter(IPostFilter filter)
 {
 }
 public void RemovePostFilter(IPostFilter i_PostFilter)
 {
     r_PostFilters.Remove(i_PostFilter);
 }