public void NoBuilderWillBeReturnedIfTheFileDoesntExists() { var mockFileSystemhelper = new Mock <IFileSystemHelper>(); mockFileSystemhelper.Setup(f => f.FileExists(It.IsAny <string>())).Returns(false); var factory = new FileConverterFactory(mockFileSystemhelper.Object); Assert.Null(factory.ParseFile("irrelevant")); }
public void NoBuilderWillBeReturnedIfTheFileExistsButExtensionDoesNotMatchAKnownType(string extension) { var mockFileSystemhelper = new Mock <IFileSystemHelper>(); mockFileSystemhelper.Setup(f => f.FileExists(It.IsAny <string>())).Returns(true); var factory = new FileConverterFactory(mockFileSystemhelper.Object); Assert.Null(factory.ParseFile("abc" + extension)); }
public void BuilderExtensionComaprisonsAreCaseInsensitive(string path) { var mockFileSystemhelper = new Mock <IFileSystemHelper>(); mockFileSystemhelper.Setup(f => f.FileExists(It.IsAny <string>())).Returns(true); var factory = new FileConverterFactory(mockFileSystemhelper.Object); Assert.NotNull(factory.ParseFile(path)); }
public void ABuilderWillBeReturnedIfAKnownExtensionIsRecognisedAndTheFileExists(string extension) { var mockFileSystemhelper = new Mock <IFileSystemHelper>(); mockFileSystemhelper.Setup(f => f.FileExists(It.IsAny <string>())).Returns(true); var factory = new FileConverterFactory(mockFileSystemhelper.Object); Assert.NotNull(factory.ParseFile("abc" + extension)); }
private void InitializeFactories() { _classConverterFactory = new ClassConverterFactory( _inputProjectPath, _lifecycleManager, _taskManager, _metricsContext); _fileConverterFactory = new FileConverterFactory( _inputProjectPath, _blazorWorkspaceManager, _webFormsProjectAnalyzer, _viewImportService, _classConverterFactory, _hostPageService, _taskManager, _metricsContext); }
public void FileConverterFactory_GetFileConverter() { const string srcExt = "src"; const string destExt = "dest"; var fcf1 = new FileConverterFactory(null); fcf1.GetFileConverter(srcExt, destExt).ShouldBeNull(); var fcs = new Mock <IFileConverter>(); var fcf2 = new FileConverterFactory(new[] { fcs.Object }); fcf2.GetFileConverter(srcExt, destExt).ShouldBeNull(); fcs.Setup(f => f.SupportedConversions).Returns(new[] { new FileConversionData(srcExt, destExt) }); fcf2.GetFileConverter(srcExt, destExt).ShouldBe(fcs.Object); }
public void Setup() { var webFormsProjectAnalyzer = new ProjectAnalyzer(_testProjectPath, new AnalyzerResult(), new PortCoreConfiguration(), new ProjectResult()); var blazorWorkspaceManager = new WorkspaceManagerService(); var taskManagerService = new TaskManagerService(); blazorWorkspaceManager.CreateSolutionFile(); WebFormMetricContext metricContext = new WebFormMetricContext(); _fileConverterFactory = new FileConverterFactory( _testProjectPath, blazorWorkspaceManager, webFormsProjectAnalyzer, new ViewImportService(), new ClassConverterFactory(string.Empty, new LifecycleManagerService(), taskManagerService, metricContext), new HostPageService(), taskManagerService, metricContext); }
private void On_Load() { _tunes = new List <Tune>(); //var p = new Project { TuneFilenames = new[] { "abc", "def" } }; //string x = JsonConvert.SerializeObject(p); var fileConverterFactory = new FileConverterFactory(new FileSystemHelper()); try { var project = Project.OpenProject(Path.Combine(Directory.GetCurrentDirectory(), "TestProject")); foreach (var fileName in project.TuneFilenames) { var metaDataPath = Path.Combine(project.WorkingFolder, "MetaData"); Directory.CreateDirectory(metaDataPath); var tunePath = Path.Combine(project.WorkingFolder, fileName); var rawTunePath = Path.ChangeExtension(Path.Combine(metaDataPath, fileName), "m6raw"); var summaryPath = Path.ChangeExtension(Path.Combine(metaDataPath, fileName), "summary"); IFileConverter converter; if ((converter = fileConverterFactory.ParseFile(rawTunePath)) == null) { converter = fileConverterFactory.ParseFile(tunePath); } if (converter == null) { continue; } var waveData = converter.ProcessFile(); if (waveData == null) { continue; } if (!File.Exists(rawTunePath)) { try { using (var rawFile = File.Create(rawTunePath)) { Serializer.Serialize(rawFile, waveData); } } catch (Exception ex) { Console.WriteLine(ex); } } var tune = new Tune(waveData); SummaryCollection summaryData = null; try { using (var summaryFile = File.OpenRead(summaryPath)) { summaryData = Serializer.Deserialize <SummaryCollection>(summaryFile); } tune.SummaryCollection = summaryData; } catch (Exception ex) { Console.WriteLine(ex); } if (summaryData == null) { tune.BuildSummaries(); try { using (var summaryFile = File.Create(summaryPath)) { Serializer.Serialize(summaryFile, tune.SummaryCollection); } } catch (Exception ex) { Console.WriteLine(ex); } } tune.StartTick = 0; tune.Track = _tunes.Count; _tunes.Add(tune); } _delta = new Delta(); _ticksPerPixel = 1024; _bbBitmap = new Bitmap(ClientRectangle.Width, ClientRectangle.Height); _desktopRange = new Range(0, ClientRectangle.Width * _ticksPerPixel); } catch (Exception ex) { MessageBox.Show(ex.Message); } }