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()); }
public void Creates_array_of_strings() { var result = _reflector.GetDObject(new string[] { "One", "Two", "Three" }, 5); DArray expected = new DArray { TypeHeader = "String[] (3 items)" }; expected.Add(new DValue("One")); expected.Add(new DValue("Two")); expected.Add(new DValue("Three")); result.Should().BeEquivalentTo(expected, o => o.WithStrictOrdering().IncludingAllRuntimeProperties()); }
public void Creates_array_of_ints() { var result = _reflector.GetDObject(new int[] { 1, 2, 3 }, 5); DArray expected = new DArray { TypeHeader = "Int32[] (3 items)" }; expected.Add(new DValue("1")); expected.Add(new DValue("2")); expected.Add(new DValue("3")); result.Should().BeEquivalentTo(expected, o => o.WithStrictOrdering().IncludingAllRuntimeProperties()); }
static void CountTestSub(bool trackFree) { var expectedCount = 0; var d = new DArray <object>(trackFree); for (var i = 0; i < 1000; i++) { if ((i % 3) == 0) { d[i] = new object(); expectedCount++; Assert.AreEqual(expectedCount, d.Count, "TrackFree = " + trackFree); } } for (var i = 0; i < d.Length; i++) { if ((i % 2) == 0 && d[i] != null) { Assert.IsNotNull(d[i]); d.RemoveAt(i); expectedCount--; Assert.IsNull(d[i]); Assert.AreEqual(expectedCount, d.Count, "TrackFree = " + trackFree); } } for (var i = 0; i < 50; i++) { d.Add(new object()); expectedCount++; Assert.AreEqual(expectedCount, d.Count, "TrackFree = " + trackFree); } }
static void Main(string[] args) { DArray dArray = new DArray(); dArray.Add(" 毒 ").Add(" 逆 ").Add(" 天 ").Add(" 到 ").Add(" 此 ").Add(" 一 ").Add(" 游 ").Output(); Console.ReadKey(); }
static void CountTestSub(bool trackFree) { var expectedCount = 0; var d = new DArray<object>(trackFree); for (var i = 0; i < 1000; i++) { if ((i % 3) == 0) { d[i] = new object(); expectedCount++; Assert.AreEqual(expectedCount, d.Count, "TrackFree = " + trackFree); } } for (var i = 0; i < d.Length; i++) { if ((i % 2) == 0 && d[i] != null) { Assert.IsNotNull(d[i]); d.RemoveAt(i); expectedCount--; Assert.IsNull(d[i]); Assert.AreEqual(expectedCount, d.Count, "TrackFree = " + trackFree); } } for (var i = 0; i < 50; i++) { d.Add(new object()); expectedCount++; Assert.AreEqual(expectedCount, d.Count, "TrackFree = " + trackFree); } }