public void ThisProtectedWithPrivateSetterPropertyAccess() { var code = ExpressionToCode.ToCode(() => TheProtectedWithPrivateSetterProperty); Assert.Equal("() => TheProtectedWithPrivateSetterProperty", code); }
public void MultipleCasts() { Assert.AreEqual( @"() => 1 == (int)(object)1", ExpressionToCode.ToCode(() => 1 == (int)(object)1)); }
public void NewArrayAndExtensionMethod() { Assert.AreEqual( @"() => new[] { 1.0, 2.01, 3.5 }.SequenceEqual(new[] { 1.0, 2.01, 3.5 })", ExpressionToCode.ToCode(() => new[] { 1.0, 2.01, 3.5 }.SequenceEqual(new[] { 1.0, 2.01, 3.5 }))); }
public void PlainNested() { Assert.Equal( "() => null as Parent.Nested", ExpressionToCode.ToCode(() => null as Parent.Nested)); }
public void NestedInGeneric() { Assert.Equal("() => null as ParentGen<int>.Nested", ExpressionToCode.ToCode(() => null as ParentGen <int> .Nested)); Assert.Equal("() => null as ParentGen<ParentGen<string>.Nested>.Nested", ExpressionToCode.ToCode(() => null as ParentGen <ParentGen <string> .Nested> .Nested)); }
public void FormattableStringFactory_IsRenderedAsInterpolation() => Assert.Equal( @"() => Interpolation($""abc"")", ExpressionToCode.ToCode( () => Interpolation(FormattableStringFactory.Create("abc")) ));
public void ForcedInterpolationWithNestedString() => Assert.Equal( @"() => Interpolation($""abc {""def""}"")", ExpressionToCode.ToCode(() => Interpolation($"abc {"def"}")));
public void DefaultValue() { Assert.Equal( @"() => new TimeSpan(1, 2, 3) == default(TimeSpan)", ExpressionToCode.ToCode(() => new TimeSpan(1, 2, 3) == default(TimeSpan))); }
public void IsOperator() { Assert.Equal( @"() => new object() is string", ExpressionToCode.ToCode(() => new object() is string)); }
public void ThisIndexedProperty() { var actual = ExpressionToCode.ToCode(() => this[1]); Assert.Equal("() => this[1]", actual); }
public void ComplexGenericName() { Assert.Equal( @"() => ((Func<int, bool>)(x => x > 0))(0)", ExpressionToCode.ToCode(() => ((Func <int, bool>)(x => x > 0))(0))); }
public void ThisStaticMethodCall() { var code = ExpressionToCode.ToCode(() => StaticReturnZero()); Assert.Equal("() => ExpressionToCodeLibTest.StaticReturnZero()", code); }
public void ThisMethodCall() { var code = ExpressionToCode.ToCode(() => ReturnZero()); Assert.Equal("() => ReturnZero()", code); }
public void ThePrivateStaticPropertyAccess() { var code = ExpressionToCode.ToCode(() => ThePrivateStaticProperty); Assert.Equal("() => ExpressionToCodeLibTest.ThePrivateStaticProperty", code); }
public void InterpolationWithoutArgumentsIsJustAString() => Assert.Equal( @"() => ""abc""", ExpressionToCode.ToCode(() => $"abc"));
public void EnumConstant() { Assert.Equal( @"() => new object().Equals((object)MidpointRounding.ToEven)", ExpressionToCode.ToCode(() => new object().Equals(MidpointRounding.ToEven))); }
public void ForcedInterpolationWorks() => Assert.Equal( @"() => Interpolation($""abc"")", ExpressionToCode.ToCode(() => Interpolation($"abc")));
public void PlainNested() { Assert.That( ExpressionToCode.ToCode(() => null as Parent.Nested), Is.EqualTo("() => null as Parent.Nested")); }
public void ForcedInterpolationWithOneArg() => Assert.Equal( @"() => Interpolation($""abc {3.0f}"")", ExpressionToCode.ToCode(() => Interpolation($"abc {3f}")));
[Test, Ignore] //TODO: this never worked, but it shouldn't crash public void UnboundGenericListInTypeof() { Assert.AreEqual("() => typeof(List<>)", ExpressionToCode.ToCode(() => typeof(List <>))); }
public void ForcedInterpolationWithTwoArguments() => Assert.Equal( @"() => Interpolation($""abc {3.0f} X {'a'} Y"")", ExpressionToCode.ToCode(() => Interpolation($"abc {3f} X {'a'} Y")));
[Test, Ignore] //TODO: this never worked, but it shouldn't crash public void UnboundNestedInTypeof() { Assert.AreEqual("() => typeof(Outer<,>.Nested<>)", ExpressionToCode.ToCode(() => typeof(Outer <,> .Nested <>))); }
public void GenericNested() { Assert.Equal("() => null as Parent.NestedGen<int>", ExpressionToCode.ToCode(() => null as Parent.NestedGen <int>)); Assert.Equal("() => null as Parent.NestedGen<Parent.NestedGen<object>>", ExpressionToCode.ToCode(() => null as Parent.NestedGen <Parent.NestedGen <object> >)); }
public void CanPrettyPrintVariousIndexers() => Assert.Equal( "() => new HasIndexers()[3] == new HasIndexers()[\"three\"]", ExpressionToCode.ToCode(() => new HasIndexers()[3] == new HasIndexers()["three"]) );
public void LiteralCharAndProperty() { Assert.AreEqual( @"() => new string(' ', 3).Length == 1", ExpressionToCode.ToCode(() => new string(' ', 3).Length == 1)); }
public void CharNoCast() { Assert.AreEqual( @"() => ""abc""[1] == 'b'", ExpressionToCode.ToCode(() => "abc"[1] == 'b')); }
public void MultipleDots() { Assert.AreEqual( @"() => 3.ToString().ToString().Length > 0", ExpressionToCode.ToCode(() => 3.ToString().ToString().Length > 0)); }
public void GenericMethodCall_ShouldExplicitlySpecifyTypeArguments() { Assert.Equal( "() => MakeMe<Cake, string>(() => new Cake())", ExpressionToCode.ToCode(() => MakeMe <Cake, string>(() => new Cake()))); }
public void NewMultiDimArray() { Assert.AreEqual( @"() => new int[3, 4].Length == 1", ExpressionToCode.ToCode(() => new int[3, 4].Length == 1)); }
public void AsOperator() { Assert.Equal( @"() => new object() as string == default(string)", ExpressionToCode.ToCode(() => new object() as string == null)); }