Exemplo n.º 1
0
        public async Task Given_A_Valid_Article_Should_Invoke_GetTipRelatedCards_Method_Once()
        {
            // Arrange
            const int expected = 1;
            var       article  = new Article {
                Title = "Call of the Haunted"
            };

            _wikiArticle.Simple(Arg.Any <long>()).Returns(new ContentResult
            {
                Sections = new[]
                {
                    new Section
                    {
                        Title   = "Call of the Haunted",
                        Level   = 1,
                        Content = new[]
                        {
                            new SectionContent
                            {
                                Type     = "list",
                                Elements = new[]
                                {
                                    new ListElement
                                    {
                                        Text     = "This card can be searched by \"A Cat of Ill Omen\" and \"The Despair Uranus\".",
                                        Elements = new ListElement[0]
                                    },
                                }
                            },
                        }
                    },
                    new Section
                    {
                        Title   = "References",
                        Content = new SectionContent[0]
                    },
                    new Section
                    {
                        Title   = "List",
                        Content = new []
                        {
                            new SectionContent
                            {
                                Elements = new[]
                                {
                                    new ListElement
                                    {
                                        Text = "Ancient Fairy Dragon"
                                    },
                                    new ListElement
                                    {
                                        Text = "Blaster, Dragon Ruler of Infernos"
                                    },
                                    new ListElement
                                    {
                                        Text = "Cyber Jar"
                                    }
                                }
                            }
                        }
                    },
                }
            });

            var handler = Substitute.For <IQueue>();

            handler.Handles(Arg.Any <string>()).Returns(true);
            handler.Publish(Arg.Any <CardSectionMessage>()).Returns(Task.CompletedTask);

            _queues.GetEnumerator().Returns(new List <IQueue> {
                handler
            }.GetEnumerator());

            // Act
            await _sut.ProcessItem(article);

            // Assert
            _tipRelatedWebPage.Received(expected).GetTipRelatedCards(Arg.Any <CardSection>(), Arg.Any <Article>());
        }