public void usings_are_ordered_system_first_then_alphabetically()
        {
            var isFailed = false;
            var builder  = new StringBuilder();

            foreach (var sourcePath in ConventionsHelper.GetCSharpSourcePaths())
            {
                var source     = File.ReadAllText(sourcePath);
                var syntaxTree = CSharpSyntaxTree.ParseText(source);
                var usings     = ((CompilationUnitSyntax)syntaxTree.GetRoot()).Usings;
                var sorted     = usings.OrderBy(u => u, UsingComparer.Instance).ToList();

                if (usings.SequenceEqual(sorted) == false)
                {
                    isFailed = true;

                    builder.AppendLine($"Usings ordered incorrectly in '{sourcePath}'");
                    builder.Append("    (");
                    builder.Append(string.Join(", ", sorted));
                    builder.AppendLine(")");
                }
            }

            isFailed.ShouldBeFalse(builder.ToString());
        }
        public void DateTime_Now_is_never_used()
        {
            var sourcePaths = ConventionsHelper.GetCSharpSourcePaths()
                              .Where(path => path.EndsWith("\\Time.cs") == false);

            foreach (var sourcePath in sourcePaths)
            {
                var source                 = File.ReadAllText(sourcePath);
                var tree                   = CSharpSyntaxTree.ParseText(source);
                var memberAccesses         = tree.GetRoot().DescendantNodes().OfType <MemberAccessExpressionSyntax>().ToList();
                var dateTimeNowInvocations = memberAccesses.Where(x =>
                                                                  x.Expression.Parent.ToString().Equals("datetime.now", StringComparison.OrdinalIgnoreCase));

                dateTimeNowInvocations.ShouldBeEmpty();
            }
        }
        public void source_code_does_not_contain_tabs()
        {
            var isFailed = false;
            var builder  = new StringBuilder();

            foreach (var sourcePath in ConventionsHelper.GetCSharpSourcePaths())
            {
                var source     = File.ReadAllText(sourcePath);
                var syntaxTree = CSharpSyntaxTree.ParseText(source);

                var hasTabs =
                    syntaxTree.GetRoot()
                    .DescendantTrivia(descendIntoTrivia: true)
                    .Any(node => node.IsKind(SyntaxKind.WhitespaceTrivia) && node.ToString().IndexOf('\t') >= 0);

                if (hasTabs)
                {
                    isFailed = true;
                    builder.AppendLine($"Found tabs in file: '{sourcePath}'");
                }
            }

            isFailed.ShouldBeFalse(builder.ToString());
        }