public void GivenMoreComplexObject_WhenDumping_ThenShouldReturnCorrectString() { // Arrange object varToDump = new { Id = 42, PropertyString = "toto", PropertyDouble = 4.2, PropertyObject = new { SubProperty1 = "SubObject", SubProperty2 = 422 } }; var expectedDump = @"{ ""Id"": 42, ""PropertyString"": ""toto"", ""PropertyDouble"": 4.2, ""PropertyObject"": { ""SubProperty1"": ""SubObject"", ""SubProperty2"": 422 } }"; // Act var resultOfVarDump = VarDump.VarDumpJson(varToDump); // Assert Assert.That(resultOfVarDump, Is.EqualTo(expectedDump), $"Essaye encore de trouver le VarDump de {varToDump}"); }
public void GivenSimpleObject_WhenDumping_ThenShouldReturnCorrectString(object varToDump, object expectedResult) { // Arrange & Act var resultOfVarDump = VarDump.VarDumpJson(varToDump); // Assert Assert.That(resultOfVarDump, Is.EqualTo(expectedResult), $"Essaye encore de trouver le VarDump de {varToDump}, type: {varToDump.GetType().Name}, depth: 1"); }
/// <summary> /// Extension do dump any object, only public properties. /// </summary> /// <typeparam name="T">any type</typeparam> /// <param name="objectToDump">object to dump</param> /// <returns></returns> public static string Dump <T>(this T objectToDump) { return(VarDump.VarDumpJson(objectToDump)); }