public AudioLoopbackViewModel() { loopbackRecorder = new LoopbackRecorder(); loopbackRecorder.StartRecording(LoopbackRecorder.GetDevices().defaultDevice, (ArraySegment <byte> dataToSend, WaveFormat format) => { RecordingDataAvailable?.Invoke(dataToSend, format); if (Analyzer != null) { var dataSize = dataToSend.Count; var tempData = ArrayPool <byte> .Shared.Rent(dataSize); Buffer.BlockCopy(dataToSend.Array, dataToSend.Offset, tempData, 0, dataSize); var tempDataView = new ArraySegment <byte>(tempData, 0, dataSize); Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { Analyzer.AddData(tempDataView, format); ArrayPool <byte> .Shared.Return(tempData); })); } }); Analyzer = new AnalyzerViewModel(loopbackRecorder.WaveFormat); Analyzer.BinsUpdated += Analyzer_BinsUpdated; }
public void CanAnalyze_NoPath_IsDisabled() { // arrange var analyzerViewModel = new AnalyzerViewModel(null); // act analyzerViewModel.FilePath = NO_PATH; var result = analyzerViewModel.CmdAnalyze.CanExecute(); // assert Assert.That(result, Is.False); }
public ActionResult SubmitUrlforAnalysis(AnalyzerViewModel viewModel) { var webPageWords = HtmlParser.WordParser(viewModel.TestUrl); viewModel.WebPageWordCount = webPageWords.Sum(w => w.Value); var top10words = webPageWords.Take(10).ToList(); viewModel.Top10WebPageWords = webPageWords.Take(10).ToList(); viewModel.WebPageImages = HtmlParser.GetImageSources(viewModel.TestUrl); return(View("Index", viewModel)); }
public void OnCmdAnalyze_ValidPath_ExpectedResult() { // arrange var ocrProviderMock = A.Fake <IOcrProvider>(); var analyzerViewModel = new AnalyzerViewModel(ocrProviderMock); analyzerViewModel.FilePath = VALID_PATH; // act analyzerViewModel.CmdAnalyze.Execute(); // assert A.CallTo(() => ocrProviderMock.Analyze(VALID_PATH)).MustHaveHappenedOnceExactly(); }
public void CmdAnalyze_SamplePdf_GetTextAndQrCode() { // arrange var analyzerViewModel = new AnalyzerViewModel(new IronOcrProvider()); analyzerViewModel.FilePath = SharedFunctions.GetPathToSamplePdf(); // act analyzerViewModel.CmdAnalyze.Execute(); // assert Assert.That(analyzerViewModel.ExtractedText, Contains.Substring(SharedValues.OCR_TEXT_PART)); Assert.That(analyzerViewModel.QrCodeValue, Contains.Substring(SharedValues.QR_CODE_VALUE_PART)); }
public void CustomizeView(AnalyzerModel model, NodeView nodeView) { nodeModel = nodeView.ViewModel.NodeModel; nodeViewModel = nodeView.ViewModel; convertModel = model; exporterControl = new AnalyzerView(model, nodeView) { DataContext = new AnalyzerViewModel(model, nodeView), }; exporterViewModel = exporterControl.DataContext as AnalyzerViewModel; nodeView.inputGrid.Children.Add(exporterControl); exporterControl.Loaded += converterControl_Loaded; //exporterControl.SelectExportedUnit.PreviewMouseUp += SelectExportedUnit_PreviewMouseUp; }
public void OnCmdAnalyze_ValidPath_CorrectReturnValueAssignments() { // arrange var ocrProviderStub = A.Fake <IOcrProvider>(); A.CallTo(() => ocrProviderStub.Analyze(VALID_PATH)).Returns(new AnalyzeResult(FULLTEXT_VALUE, QR_CODE_VALUE)); var analyzerViewModel = new AnalyzerViewModel(ocrProviderStub); analyzerViewModel.FilePath = VALID_PATH; // act analyzerViewModel.CmdAnalyze.Execute(); // assert Assert.That(analyzerViewModel.ExtractedText, Is.EqualTo(FULLTEXT_VALUE)); Assert.That(analyzerViewModel.QrCodeValue, Is.EqualTo(QR_CODE_VALUE)); }
// GET: Analysis public ActionResult Index() { AnalyzerViewModel viewModel = new AnalyzerViewModel(); return(View(viewModel)); }
public AnalyzerView() { DataContext = new AnalyzerViewModel(new IronOcrProvider()); InitializeComponent(); }
private async Task <AnalyzerViewModel> Analyze(Analyzer analyzer) { var viewModel = new AnalyzerViewModel { Analyzer = analyzer }; if (analyzer == null || string.IsNullOrEmpty(analyzer.SearchText)) { return(viewModel); } IAnalysisService service; if (analyzer.IsURL) { service = new AnalysisUrlService(); } else { service = new AnalysisTextService(); } if (analyzer.IsCountNumberofWords) { viewModel.AllWordsInfo = await service.GetAllWordsInfo(analyzer.SearchText, analyzer.IsPageFilterStopWords); ViewBag.WordSortParm = string.IsNullOrEmpty(analyzer.WordSortBy) ? "word_desc" : "word"; ViewBag.CountSortParm = analyzer.WordSortBy == "count" ? "count_desc" : "count"; if (!string.IsNullOrEmpty(analyzer.WordSortBy)) { switch (analyzer.WordSortBy) { case "word_desc": viewModel.AllWordsInfo = viewModel.AllWordsInfo.OrderByDescending(a => a.Key).ToDictionary(a => a.Key, a => a.Value); break; case "count": viewModel.AllWordsInfo = viewModel.AllWordsInfo.OrderBy(a => a.Value).ToDictionary(a => a.Key, a => a.Value); break; case "count_desc": viewModel.AllWordsInfo = viewModel.AllWordsInfo.OrderByDescending(a => a.Value).ToDictionary(a => a.Key, a => a.Value); break; default: viewModel.AllWordsInfo = viewModel.AllWordsInfo.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value); break; } } } if (analyzer.IsMetaTagsInfo) { viewModel.AllMetaTagsInfo = await service.GetAllMetaTagsInfo(analyzer.SearchText, analyzer.IsPageFilterStopWords); ViewBag.MetaWordSortParm = string.IsNullOrEmpty(analyzer.MetaSortBy) ? "word_desc" : "word"; ViewBag.MetaCountSortParm = analyzer.MetaSortBy == "count" ? "count_desc" : "count"; if (!string.IsNullOrEmpty(analyzer.MetaSortBy)) { switch (analyzer.MetaSortBy) { case "word_desc": viewModel.AllMetaTagsInfo = viewModel.AllMetaTagsInfo.OrderByDescending(a => a.Name).ToList(); break; case "count": viewModel.AllMetaTagsInfo = viewModel.AllMetaTagsInfo.OrderBy(a => a.TotalWordCount).ToList(); break; case "count_desc": viewModel.AllMetaTagsInfo = viewModel.AllMetaTagsInfo.OrderByDescending(a => a.TotalWordCount).ToList(); break; default: viewModel.AllMetaTagsInfo = viewModel.AllMetaTagsInfo.OrderBy(a => a.Name).ToList(); break; } } } if (analyzer.IsGetExternalLink) { viewModel.AllExternalLinks = await service.GetAllExternalLinks(analyzer.SearchText); ViewBag.LinkWordSortParm = string.IsNullOrEmpty(analyzer.LinkSortBy) ? "word_desc" : "word"; ViewBag.LinkCountSortParm = analyzer.LinkSortBy == "count" ? "count_desc" : "count"; if (!string.IsNullOrEmpty(analyzer.LinkSortBy)) { switch (analyzer.LinkSortBy) { case "word_desc": viewModel.AllExternalLinks = viewModel.AllExternalLinks.OrderByDescending(a => a.Key).ToDictionary(a => a.Key, a => a.Value); break; case "count": viewModel.AllExternalLinks = viewModel.AllExternalLinks.OrderBy(a => a.Value).ToDictionary(a => a.Key, a => a.Value); break; case "count_desc": viewModel.AllExternalLinks = viewModel.AllExternalLinks.OrderByDescending(a => a.Value).ToDictionary(a => a.Key, a => a.Value); break; default: viewModel.AllExternalLinks = viewModel.AllExternalLinks.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value); break; } } } service.Dispose(); return(viewModel); }