Ejemplo n.º 1
0
        public void ResXAndDesignerFilesShouldBeConsistentAndNotCauseUnnecessaryMergeConflicts()
        {
            List <string> resxFiles = new();

            foreach (string file in System.IO.Directory.GetFiles(BaselineHelper.GetAbsolutePathRelativeToRepoRoot(""), "*.resx", SearchOption.AllDirectories))
            {
                resxFiles.Add(file);
            }
            resxFiles.Should().HaveCountGreaterThan(2, "There should be at least 3 resx files found in the project");

            foreach (string resXRelativePath in resxFiles)
            {
                using (new AssertionScope(resXRelativePath))
                {
                    AssertDoesNotContainTabs(resXRelativePath, GetRelativeFileContents(resXRelativePath));
                }

                string designerRelativePath = Path.ChangeExtension(resXRelativePath, ".Designer.cs");
                using (new AssertionScope(designerRelativePath))
                {
                    string designerFileContents = GetRelativeFileContents(designerRelativePath);
                    AssertDoesNotContainTabs(designerFileContents, designerFileContents);

                    if (designerFileContents.Contains("get\n"))
                    {
                        throw new Exception($"{designerRelativePath} should be formatted with this style:\n\n  get\n  {{\n\nand not this style:\n\n  get {{\n\n{Info}");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private string GetRelativeFileContents(string relativePath)
        {
            var path = BaselineHelper.GetAbsolutePathRelativeToRepoRoot(relativePath);

            return(File.ReadAllText(path));
        }