public async Task ProductTest(SentimentAspectData data) { log.LogInformation("ProductTest: {0}", data); var aspectHandler = new MainAspectHandler(new AspectContextFactory()); var runner = new TestRunner(TestHelper.Instance, data.Sentiment); var semaphore = new SemaphoreSlim(Environment.ProcessorCount / 2, Environment.ProcessorCount / 2); IObservable <IParsedDocumentHolder> result = runner.Load().ObserveOn(TaskPoolScheduler.Default).Select(review => ProcessItem(semaphore, aspectHandler, review)).Merge(); await result; IAspectSerializer serializer = TestHelper.Instance.ContainerHelper.Resolve <IAspectSerializer>(); serializer.Serialize(aspectHandler).Save(Path.Combine(TestContext.CurrentContext.TestDirectory, data.Sentiment.Product + ".xml")); Text.Words.IWordItem[] features = aspectHandler.GetFeatures(10).ToArray(); Text.Words.IWordItem[] attributes = aspectHandler.GetAttributes(10).ToArray(); for (var i = 0; i < data.Features.Items.Length; i++) { Assert.IsTrue(features.Any(item => string.Compare(item.Text, data.Features.Items[i], StringComparison.OrdinalIgnoreCase) == 0)); } for (var i = 0; i < data.Attributes.Items.Length; i++) { Assert.IsTrue(attributes.Any(item => string.Compare(item.Text, data.Attributes.Items[i], StringComparison.OrdinalIgnoreCase) == 0)); } }
public void Construct() { Assert.Throws <ArgumentNullException>(() => new MainAspectHandler(null)); Assert.AreEqual(0, instance.GetFeatures(10).ToArray().Length); Assert.AreEqual(0, instance.GetAttributes(10).ToArray().Length); }