Example #1
0
        public void Create_Always_ReturnsCreatedResult()
        {
            // arrange
            const int ARTICLE_ID     = 123;
            var       createdSummary = new ArticleSummary
            {
                Id = ARTICLE_ID
            };

            _mockArticleRepository.Setup(r => r.Create(It.IsAny <ArticleSaveData>())).Returns(createdSummary);

            // act
            var saveData = new ArticleSaveData();
            var result   = _articlesController.Create(saveData);

            // assert
            Assert.IsInstanceOfType(result, typeof(CreatedResult));
            var createdResult = (CreatedResult)result;

            Assert.AreEqual($"./{ARTICLE_ID}", createdResult.Location);
            Assert.IsInstanceOfType(createdResult.Value, typeof(ArticleSummary));
            var actualSummary = (ArticleSummary)createdResult.Value;

            Assert.AreEqual(ARTICLE_ID, actualSummary.Id);
        }
Example #2
0
        public void Create_Always_CallsRepositoryWithData()
        {
            // arrange
            const string ARTICLE_TITLE    = "article title";
            var          incomingSaveData = new ArticleSaveData
            {
                Title = ARTICLE_TITLE
            };
            var createdSummary = new ArticleSummary();

            _mockArticleRepository.Setup(r => r.Create(It.IsAny <ArticleSaveData>())).Returns(createdSummary);

            // act
            _articlesController.Create(incomingSaveData);

            // assert
            _mockArticleRepository.Verify(r => r.Create(It.Is <ArticleSaveData>(sd => sd.Title == ARTICLE_TITLE)));
        }
        private void ButtonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (TextboxUrlInput.Text.Length > 0)
            {
                // Grab URLs entered by user
                var      rawUrls = TextboxUrlInput.Text;
                string[] urls    = rawUrls.Split('\n');
                var      obj     = App.Current as App;

                // Generate a summary for each URL given and add to queue
                foreach (var url in urls)
                {
                    ArticleSummary tempArticle = ArticleSummarizer.Generate(url.Trim('\r'));
                    obj.Articles.Enqueue(tempArticle);
                }

                // Launch the first summary window
                OpenNewWindow();
            }
        }
        public Task Aggregate(ArticleSummary article)
        {
            Task Aggregate()
            {
                Indexing = true;
                var doc = new Document {
                    new TextField("abstract", article.Abstract, Field.Store.YES),
                    new TextField("title", article.Title, Field.Store.YES),
                    new StringField("tag", article.Tags.First(), Field.Store.YES),
                    new TextField("author", article.Author.Name, Field.Store.YES),
                    new TextField("id", article.Id.ToString(), Field.Store.YES)
                };

                Writer.AddDocument(doc);
                Writer.Commit();
                Indexing = false;
                return(Task.CompletedTask);
            }

            CommitChanges();
            return(SerialExecutor.AddNext(Aggregate));
        }
Example #5
0
        public static ArticleSummary CreateArticleSummaryTest()
        {
            var summary = new ArticleSummary
            {

                DateCreated = new DateElement(DateTime.Now),
                Editor = new UserElement()
                {
                    user = UserTest.CreateTestUser()
                },
                H2G2ID = 1,
                LastUpdated = new DateElement(DateTime.Now),
                Name = "Test",
                SortOrder = 1,
                Status = new ArticleStatus()
                {
                    Type = 1,
                    Value = "1"
                },
                StrippedName = "StrippedName"
            };
            return summary;
        }
Example #6
0
 public ProductSummary()
 {
     Article = new ArticleSummary();
 }
 public SummaryWindow(ArticleSummary article)
 {
     Article = article;
     InitializeComponent();
 }