From 9fba0fa717ee98839c13a6a6bb860f091eb0383b Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 10:28:20 +0300 Subject: [PATCH] Fixed creating instance wrongly --- .../Contents/ContentParser_Test.cs | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs index f1b877bac8..00dc4c184e 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs @@ -10,13 +10,12 @@ public class ContentParser_Test : CmsKitDomainTestBase { private readonly CmsKitTestData testData; private readonly IOptions _options; - private readonly ContentParser contentParser; + private ContentParser contentParser; public ContentParser_Test() { testData = GetRequiredService(); _options = GetRequiredService>(); - contentParser = GetRequiredService(); } [Fact] @@ -24,6 +23,7 @@ public class ContentParser_Test : CmsKitDomainTestBase { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); _options.Value.AddWidgetConfig("ImageGallery", new ContentWidgetConfig("ImageGallery"));//test + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Type=""Poll"" PollName =""poll-name""] @@ -43,55 +43,58 @@ public class ContentParser_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(1);//Ignored Widget + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(1);//Ignored Widget } [Fact] public async Task ParseAsync_ShouldWorkWithWrongConfigOptions() { _options.Value.AddWidgetConfig(testData.WidgetName, new ContentWidgetConfig(testData.PollName)); + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(2); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(2); } [Fact] public async Task ParseAsync_ShouldWorkWithWrongWidgetType() { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Wrong Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(2); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(2); } [Fact] public async Task ParseAsync_ShouldWorkWithWrongPollName() { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Type= ""Poll"" PollWrongName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(2); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(2); } [Theory] @@ -99,11 +102,12 @@ public class ContentParser_Test : CmsKitDomainTestBase public async Task ParseAsync_ShouldWorkProperlyWithCorrectInputs(string content, int expectedLine) { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + contentParser = new ContentParser(_options); - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(expectedLine); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(expectedLine); } public static IEnumerable ExampleData =>