Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using Microsoft.Extensions.Configuration;
  2. using Moq;
  3. using NUnit.Framework;
  4. using TradeCore.Analyzers.Keywords;
  5. using TradeCore.Model.Interfaces.Analyzers;
  6.  
  7. namespace TradeCore.Analyzers.IntegrationTests
  8. {
  9.     public class ParallelDotsApiTests
  10.     {
  11.         private IKeywordsAnalyzer _keywordsAnalyzer;
  12.         private Mock<IConfiguration> _configurationMock;
  13.         private Mock<IConfigurationSection> _configurationSectionMock;
  14.  
  15.         private const string ApiKey = "lasDoZerYi4MUtUkpooRvMfAqRzIwnpxtklN5sfbu70";
  16.  
  17.         [SetUp]
  18.         public void Setup()
  19.         {
  20.             _configurationMock = new Mock<IConfiguration>();
  21.             _configurationSectionMock = new Mock<IConfigurationSection>();
  22.  
  23.             _configurationSectionMock.Setup(s => s.Value).Returns(ApiKey);
  24.             _configurationMock.Setup(c => c.GetSection(It.IsAny<string>())).Returns(_configurationSectionMock.Object);
  25.  
  26.             _keywordsAnalyzer = CreateParallelDotsKeywordsAnalyzer(_configurationMock.Object);
  27.         }
  28.  
  29.         [Test]
  30.         public void SuggestKeywords_RequestKeywordsByApi_GetKeywords()
  31.         {
  32.             var text =
  33.                 "Global warming set to exceed Paris agreement’s 1.5C limit by 2040s, according to draft UN report\', \'There is a tipping point’: UN warns climate change goals laid out in Paris accord are almost out of reach";
  34.  
  35.             var keywords = _keywordsAnalyzer.SuggestKeywords(text);
  36.  
  37.             Assert.True(keywords.Count > 0);
  38.         }
  39.  
  40.         private IKeywordsAnalyzer CreateParallelDotsKeywordsAnalyzer(IConfiguration configuration)
  41.         {
  42.             return new ParallelDotsKeywordsAnalyzer(configuration);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement