public void TestParsingExceptions() { var noColon = new StringReader("foobar"); Assert.Throws(typeof(FormatException), () => SolutionMetadata.ParseFrom(noColon)); var emptyKey = new StringReader(" : bar"); Assert.Throws(typeof(FormatException), () => SolutionMetadata.ParseFrom(emptyKey)); var emptyValue = new StringReader("foo : "); Assert.Throws(typeof(FormatException), () => SolutionMetadata.ParseFrom(emptyValue)); var duplicateKey = new StringReader("foo: bar\nfoo: bar"); Assert.Throws(typeof(FormatException), () => SolutionMetadata.ParseFrom(duplicateKey)); var invalidCreationDate = new StringReader("CreationDate: foobar"); Assert.Throws(typeof(FormatException), () => SolutionMetadata.ParseFrom(invalidCreationDate)); }
public static SolutionMetadata CreateSolutionMetadata( string name, bool sourceInformationIsNull, bool solutionIsNull, out SourceInformation sourceInformation, out Solution solution) { sourceInformation = null; if (!sourceInformationIsNull) { sourceInformation = CreateTestSourceInformation(); } solution = null; if (!solutionIsNull) { solution = CreateTestSolution(); } var output = new SolutionMetadata(name, sourceInformation, solution); return(output); }
protected override void Load(ContainerBuilder builder) { builder.RegisterType <AccountingNancyModule>() .As <INancyModule>() .PropertiesAutowired(PropertyWiringOptions.PreserveSetValues) .SingleInstance(); var solutionMetadata = new SolutionMetadata(); builder.RegisterInstance(solutionMetadata).AsImplementedInterfaces(); base.Load(builder); }
static SolutionMetadata PrepareData() { SolutionMetadata solution = new SolutionMetadata(); solution.Name = "Savory"; solution.Guid = Guid.NewGuid(); #region Projects solution.Projects = new List <ProjectBase>(); //Database SqlServerProject sqlProjectMetadata = new SqlServerProject(); sqlProjectMetadata.Name = "Lucy"; sqlProjectMetadata.ProjectGuid = new Guid(); solution.Projects.Add(sqlProjectMetadata); //Dal CSharpDalProject projectDalMeta = new CSharpDalProject(); projectDalMeta.Name = "Terminal"; projectDalMeta.ProjectGuid = Guid.NewGuid(); solution.Projects.Add(projectDalMeta); //Utility CSharpUtilityProject projectUtilityMeta = new CSharpUtilityProject(); projectUtilityMeta.Name = "Terminal"; projectUtilityMeta.ProjectGuid = Guid.NewGuid(); solution.Projects.Add(projectUtilityMeta); //Business CSharpBusinessProject projectBusinessMeta = new CSharpBusinessProject(); projectBusinessMeta.Name = "Terminal"; projectBusinessMeta.ProjectGuid = Guid.NewGuid(); projectBusinessMeta.ReferencedProjects = new List <CSharpProjectBase>(); projectBusinessMeta.ReferencedProjects.Add(projectDalMeta); projectBusinessMeta.ReferencedProjects.Add(projectUtilityMeta); solution.Projects.Add(projectBusinessMeta); #endregion return(solution); }
public static void MapFromSolution_ReturnsExpectedResult() { var solution = Helpers.CreateTestSolution(); var result = SolutionMetadata.MapFromSolution(solution); result.Should().BeEquivalentTo( solution, options => options .ExcludingMissingMembers() .Excluding(x => x.Projects) ); var stuff = result.ProjectMetadatas.Cast <Project>().ToList(); stuff.Should().AllBeEquivalentTo( solution.Projects, options => options.ExcludingMissingMembers()); }
public void TestParsing() { var str = "Name: Test #01: FooBar\n" + "AuthorName : John Doe\n" + "AuthorEmail : [email protected]\n" + "UnknownKeyFooBarBaz: foobar\n" + "CreationDate: 2018-10-03 10:00\n" + "\n" + "this is not a part of metadata\n" + "Name : foobar"; var metadata = SolutionMetadata.ParseFrom(new StringReader(str)); Assert.That(metadata.Name, Is.EqualTo("Test #01: FooBar")); Assert.That(metadata.AuthorName, Is.EqualTo("John Doe")); Assert.That(metadata.AuthorEmail, Is.EqualTo("*****@*****.**")); Assert.That(metadata.CreationDate, Is.EqualTo(new DateTimeOffset( new DateTime(2018, 10, 3, 10, 0, 0)))); }
private async Task SolveAsync() { _myCancellationTokenSource = new CancellationTokenSource(); SolutionInstance = null; try { IsWorking = true; InputHandler.ClearResults(SolutionMetadata.Day); SolutionInstance = SolutionMetadata.CreateInstance(); SolutionInstance.MillisecondsBetweenProgressUpdates = MillisBetweenProgressRender / 2; SolutionInstance.CancellationToken = _myCancellationTokenSource.Token; SolutionInstance.ProgressUpdated += OnProgressUpdate; CalculationStopwatch = Stopwatch.StartNew(); foreach (var(part, index) in new Func <string, Task <string> >[] { SolutionInstance.Part1Async, SolutionInstance.Part2Async }.Select((x, i) => (x, i))) { Progress = new SolutionProgress(); StateHasChanged(); await Task.Delay(1); if (IsWorking == false) { break; } Results[index] = await ExceptionToResult(part); } } finally { if (SolutionInstance != null) { SolutionInstance.ProgressUpdated -= OnProgressUpdate; } IsWorking = false; CalculationStopwatch?.Stop(); } }
private void ProcessGitVersionFile(SolutionMetadata solutionMetadata) { _logger.Trace("Entering"); var gitVersionInformation = Tools.GetChildFileInformation( solutionMetadata.SourceInformation, "GitVersion.yml"); if (gitVersionInformation != null) { var sourceTool = GetSourceTool(); var sw = Stopwatch.StartNew(); var content = sourceTool.GetItemContent(gitVersionInformation); sw.Stop(); _logger.Trace($"GetItemContent took {sw.Elapsed}"); if (content != null) { solutionMetadata.GitVersion = GitVersionParser.ParseGitVersionContent(content); } } }
public void TestPrinting() { string data0 = "Name: Test #01: FooBar\n" + "AuthorName : John Doe\n" + "AuthorEmail : [email protected]\n" + "CreationDate: 2018-10-03 10:00"; var meta1 = SolutionMetadata.ParseFrom(new StringReader(data0)); var writer1 = new StringWriter(); meta1.PrintTo(writer1); var data1 = writer1.ToString(); var meta2 = SolutionMetadata.ParseFrom(new StringReader(data1)); var writer2 = new StringWriter(); meta2.PrintTo(writer2); var data2 = writer2.ToString(); Assert.That(data1, Is.EqualTo(data2)); }
public static void Constructor1_Succeeds() { var result = new SolutionMetadata(); Assert.That(result, Is.Not.Null); }
public SolutionTemplate(SolutionMetadata solution) { this.Guid = solution.Guid; this.Projects = solution.Projects; }
private SolutionMetadata ProcessSolution(SourceInformation solutionSourceInformation) { _logger.Trace("Entering"); var sourceTool = GetSourceTool(); var sw = Stopwatch.StartNew(); var content = sourceTool.GetItemContent(solutionSourceInformation); sw.Stop(); _logger.Trace($"GettItemContent took {sw.Elapsed}"); var solutionParser = new SolutionParser(); var solution = solutionParser.ParseSolutionFileContent(content); var name = Path.GetFileNameWithoutExtension(solutionSourceInformation.SourcePath); var solutionMetadata = new SolutionMetadata(name, solutionSourceInformation, solution); OnItemProcessing(new ItemParsingEventArgs(solutionSourceInformation)); if (_parseGitVersionFiles) { ProcessGitVersionFile(solutionMetadata); } if (solutionMetadata.Projects != null) { var exceptions = new ConcurrentQueue <Exception>(); Parallel.ForEach( solutionMetadata.Projects, _performanceConfiguration.ParallelOptions, project => { var projectSourceInformation = new SourceInformation(solutionSourceInformation) { SourcePath = Tools.GetDirectoryInformation(solutionSourceInformation).SourcePath + project.PathRelativeToSolution }; try { if (project.PathRelativeToSolution.EndsWith( ".csproj", StringComparison.CurrentCultureIgnoreCase)) { var projectMetadata = ProcessProject(projectSourceInformation); projectMetadata.SourceInformation = projectSourceInformation; var projectDirectory = Tools.GetDirectoryInformation(projectSourceInformation); if (_parsePackageConfigFiles) { ProcessPackagesConfig(projectMetadata, projectDirectory); } if (_parseConfigFiles) { ProcessConfigFiles(projectMetadata, projectDirectory); } if (_parseAssemblyInfoFiles) { ProcessAssemblyInfo(projectMetadata, projectDirectory); } solutionMetadata.ProjectMetadatas.Add(projectMetadata); } // todo Parse SQL Projects? } catch (Exception e) { OnExceptionThrown(new ExceptionEventArgs(projectSourceInformation, e)); exceptions.Enqueue(e); } } ); if (exceptions.Any()) { throw new AggregateException( $"Some project processing failed for {solutionSourceInformation}.", exceptions); } } return(solutionMetadata); }
public EntityTypeHandler(SolutionMetadata solution) { _solution = solution; }