Beispiel #1
0
        /// <summary>
        /// Poll endpoints for new items
        /// </summary>
        private void PollEndpoints()
        {
            PollingEndpoints.ForEach(pollingEndpoint =>
            {
                // get new items from endpoint
                List <T> newItems = pollingEndpoint.Poll();

                // for those items that pass all filters, convert to content
                List <IContent> contentToProcess = new List <IContent>();
                newItems.ForEach(newItem =>
                {
                    if (PollingFilter.PassesFilter(newItem))
                    {
                        IContent content;
                        if (!pollingEndpoint.ProcessAsPlainText)
                        {
                            content = ContentFactory.GetContent(ComponentContainer, newItem);
                        }
                        else
                        {
                            content = (IContent)ContentFactory.GetTextContent(ComponentContainer, newItem);
                        }

                        contentToProcess.Add(content);
                    }
                });

                // process new content
                if (contentToProcess != null && contentToProcess.Count > 0)
                {
                    ContentProcessors.ForEach(contentProcessor => contentProcessor.Process(contentToProcess));
                }
            });
        }
        public void GetContentWithNoParametersReturnsDefaultContent()
        {
            var factory = new ContentFactory();

            IContent content = factory.GetContent();

            Assert.AreEqual(!default(bool), content is EmptyContent);
        }
Beispiel #3
0
    private void getContent(object sender, EventArgs e)
    {
        int cid = 1;

        if (Request.QueryString["ID"] != null)
        {
            cid = int.Parse(Request.QueryString["ID"]);
        }
        pageContent = ContentFactory.GetContent(cid);
    }
        public void SetContentAssignsSpecifiedContentToContext()
        {
            var cell = new Cell();
            var contentFactory = new ContentFactory();
            cell.SetContent(contentFactory.GetContent(ContentType.Bomb));
            ICell context = cell.GetContext();

            Assert.AreEqual(!default(bool), context.Content is Bomb);
            Assert.AreEqual((CellState)default(int), context.State);
        }
        public void CalculateSurroundingBombsOnCellWithBombShouldReturnZero()
        {
            var contentFactory = new ContentFactory();
            var settings = new EasyBoardSettings();
            var subscribers = new List<IBoardObserver>()
            {
            };

            var board = new Board(settings, subscribers);
            this.FillBoard(board);

            board.Cells[default(int), default(int)].Content = contentFactory.GetContent(ContentType.Bomb);

            int result = board.CalculateNumberOfSurroundingBombs(default(int), default(int));

            Assert.AreEqual(default(int), result);
        }
 /// <summary>
 /// A method for filling the playing board with cells 
 /// </summary>
 /// <param name="board">The current playing board to be filled</param>
 private void FillBoard(IBoard board)
 {
     var contentFactory = new ContentFactory();
     for (var row = 0; row < board.Rows; row++)
     {
         for (int col = 0; col < board.Cols; col++)
         {
             board.Cells[row, col] = new Cell()
                 .SetContent(contentFactory.GetContent(ContentType.Empty))
                 .SetState(CellState.Sealed)
                 .GetContext();
         }
     }
 }