예제 #1
0
        public void UnstableApi()
        {
            var unstableTypes = typeof(ExpressionToCode).GetTypeInfo().Assembly.GetTypes()
                                .Where(IsPublic)
                                .Where(type => type.Namespace !.Contains("Unstable"))
                                .OrderByDescending(type => type.GetTypeInfo().IsEnum)
                                .ThenByDescending(type => type.GetTypeInfo().IsInterface)
                                .ThenBy(type => type.FullName);

            ApprovalTest.Verify(PrettyPrintTypes(unstableTypes));
        }
 public void DealsOkWithObjectsContainingLongStrings()
 {
     ApprovalTest.Verify(
         annotator.AnnotatedToCode(
             () => new {
         A_long_string     = string.Join("##", Enumerable.Range(0, 100)) + "suffix",
         A_short_string    = "short",
         A_long_enumerable = Enumerable.Range(0, 1000)
     }
             ));
 }
예제 #3
0
        public void NestedArraysUseProperConfig()
        {
            var config = ExpressionToCodeConfiguration.DefaultCodeGenConfiguration.WithPrintedListLengthLimit(3);

            ApprovalTest.Verify(config.ComplexObjectToPseudoCode(new[] {
                null,
                new {
                    A = 3,
                    B = new[] { 1, 2, 3, 4, 5 }
                }
            }));
        }
        public void MessyEnumerablesOfAnonymousObjects()
        {
            var foo = new
            {
                A_long_string     = string.Join("##", Enumerable.Range(0, 100)) + "suffix",
                A_short_string    = "short",
                A_long_enumerable = Enumerable.Range(0, 1000)
            };

            ApprovalTest.Verify(
                ExpressionToCodeConfiguration.DefaultAssertionConfiguration.ComplexObjectToPseudoCode(new[] {
                foo, foo,
            }));
        }
        public void DealsOkWithEnumerablesOfAnonymousObjects()
        {
            var foo = new
            {
                A_long_string     = string.Join("##", Enumerable.Range(0, 100)) + "suffix",
                A_short_string    = "short",
                A_long_enumerable = Enumerable.Range(0, 1000)
            };

            ApprovalTest.Verify(
                annotator.AnnotatedToCode(
                    () => new[] {
                foo, foo,
            }));
        }
        public void DealsOkWithObjectsContainingLongMultilineStrings()
        {
            var wallOfText =
                string.Join("",
                            Enumerable.Range(0, 100)
                            .Select(line =>
                                    $"line {line}:".PadRight(10)
                                    + string.Join("",
                                                  Enumerable.Range(2, 20).Select(n => $"{n * 10,9};")
                                                  ) + "\n"
                                    )
                            );

            ApprovalTest.Verify(
                annotator.AnnotatedToCode(
                    () => new {
                A_wall_of_text    = wallOfText,
                A_short_string    = "short",
                A_long_enumerable = Enumerable.Range(0, 1000)
            }
                    ));
        }
예제 #7
0
 public void DealsOkWithLongStrings()
 => ApprovalTest.Verify(
     AnnotateAsAssertion(
         () => string.Join("##", Enumerable.Range(0, 100)) + "suffix"
         ));
예제 #8
0
 public void DealsOkWithLongEnumerables()
 => ApprovalTest.Verify(
     AnnotateAsAssertion(
         () => Enumerable.Range(0, 1000).ToDictionary(i => "n" + i)["n3"].ToString(CultureInfo.InvariantCulture) == 3.5.ToString(CultureInfo.InvariantCulture)
         ));