Example #1
0
        public void Creates_complex_with_cyclic_references()
        {
            var four = new Complex4();
            var five = new Complex5 {
                Four = four
            };

            four.Five = five;

            var result = _reflector.GetDObject(four, 5);

            var expected     = new DComplex("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex4", null);
            var fiveExpected = new DComplex("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex5", null);

            expected.AddProperty("Five", fiveExpected);
            fiveExpected.AddProperty("Four", new CyclicReference("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex4", Check_if_its_a_Guid));

            result.Should().BeEquivalentTo(expected, o => o.IncludingAllRuntimeProperties()
                                           .Using <string>(IsGuid)
                                           .When(m => m.RuntimeType == typeof(string)
                                                 &&
                                                 m.SelectedMemberInfo.Name == nameof(CyclicReference.Reference)
                                                 &&
                                                 m.SelectedMemberInfo.DeclaringType == typeof(CyclicReference))
                                           );
        }
Example #2
0
        public void Creates_array_of_complex()
        {
            Complex2[] complexes =
            {
                new Complex2 {
                    N1 = "Hello", N2 = "World"
                },
                new Complex2 {
                    N1 = "Hallo", N2 = "Welt"
                },
            };

            var result = _reflector.GetDObject(complexes, 5);

            var expected  = new DArray();
            var dcomplex1 = new DComplex("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex2", null);
            var dcomplex2 = new DComplex("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex2", null);

            dcomplex1.AddProperty("N1", new DValue("Hello"));
            dcomplex1.AddProperty("N2", new DValue("World"));
            dcomplex2.AddProperty("N1", new DValue("Hallo"));
            dcomplex2.AddProperty("N2", new DValue("Welt"));

            expected.Add(dcomplex1);
            expected.Add(dcomplex2);

            expected.TypeHeader = "Complex2[] (2 items)";
            expected.AddColumns(new[] { "N1", "N2" });

            result.Should().BeEquivalentTo(expected, o => o.WithStrictOrdering().IncludingAllRuntimeProperties());
        }
Example #3
0
        private void Format(DComplex complex)
        {
            Write("<table>");

            Write("<tr>");
            Write("<td colspan='2' class='type'>");
            Write(complex.TypeHeader);
            Write("</td>");
            Write("</tr>");

            foreach (var property in complex.Properties)
            {
                Write("<tr>");

                Write(Invariant($"<td class='property'>{property.Name}</td>"));

                Write("<td class='value'>");

                WriteObject(property.Value);

                Write("</td>");
                Write("</tr>");
            }

            Write("</table>");
        }
Example #4
0
File: NativeD.cs Project: mono/gert
	public static unsafe void Main (string [] args)
	{
		DComplex xD = new DComplex (42, 42);
		DComplex [] xxD = new DComplex [10], yyD = new DComplex [10];

		for (int i = 0; i < xxD.Length; i++) xxD [i] = new DComplex ((double) i, (double) 2 * i);

		fixed (void* xxd = xxD, yyd = yyD)
			addComplexD (xxD.Length, xxd, xD, yyd);

		fixed (void* xxd = xxD, yyd = yyD)
			addComplexD (xxD.Length, xxd, xD, yyd);
	}
Example #5
0
        public void Creates_complex_with_properties()
        {
            var result = _reflector.GetDObject(new Complex1 {
                Name_f = "Hello", Name_p = "World", Number_f = 17, Number_p = 42
            }, 5);

            DComplex expected = new DComplex("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex1", null);

            expected.AddProperty(nameof(Complex1.Name_f), new DValue("Hello"));  // fields will always be before properties
            expected.AddProperty(nameof(Complex1.Number_f), new DValue("17"));
            expected.AddProperty(nameof(Complex1.Name_p), new DValue("World"));
            expected.AddProperty(nameof(Complex1.Number_p), new DValue("42"));

            result.Should().BeEquivalentTo(expected, o => o.WithStrictOrdering().IncludingAllRuntimeProperties());
        }
Example #6
0
        public void Creates_complex_and_catches_exceptions_when_reading_properties()
        {
            var result = _reflector.GetDObject(new Complex3(), 5);

            var expected = new DComplex("MiP.ObjectDump.Tests.Reflection.ReflectorTests+Complex3", null);

            string systemInvalidoperationexceptionThisIsExpected = "System.InvalidOperationException: This is expected!*";

            expected.AddProperty("Throws", new DError(systemInvalidoperationexceptionThisIsExpected));
            expected.AddProperty("Name", new DValue("Hello"));

            result.Should().BeEquivalentTo(expected, o => o.WithStrictOrdering().IncludingAllRuntimeProperties()
                                           // only match first part of the exception string
                                           .Using <string>(a => StringMatching(a, systemInvalidoperationexceptionThisIsExpected))
                                           .WhenTypeIs <string>()
                                           );
        }
Example #7
0
 private void WriteArrayItem(DComplex complex, IReadOnlyDictionary <string, int> columns, string colspan)
 {
     foreach (var column in columns.OrderBy(c => c.Value))
     {
         var property = complex.Properties.FirstOrDefault(p => p.Name == column.Key);
         if (property != null)
         {
             Write("<td>");
             Format((dynamic)property.Value);
             Write("</td>");
         }
         else
         {
             Write("<td></td>"); // add empty column
         }
     }
 }
Example #8
0
File: NativeD.cs Project: mono/gert
	private static extern unsafe void addComplexD (int l, void* x, DComplex y, void* z);