public void ObjectPrinter_ShouldSerializeTypesAlternatively() { var expected = string.Join(Environment.NewLine, "Person", "\tId = 00000000-0000-0000-0000-000000000000", "\tName = John Smith", "\tHeight = 13,37", "\tAge = 69 (это инт)") + Environment.NewLine; personPrinter.Printing <int>().Using(e => e + " (это инт)"); personPrinter.PrintToString(person).Should().Be(expected); }
public void TrimStrings_When(int maxLength, string name) { var result = $"Person{_newLine}\tId = {Guid.Empty}{_newLine}\tName = {name}{_newLine}\tHeight = 160{_newLine}\tAge = 13{_newLine}" .ToHashSet(_newLine); _printer.Printing <string>() .TrimmedToLength(maxLength) .PrintToString(_person) .ToHashSet(_newLine) .Should() .BeEquivalentTo(result); }
public void ObjectPrinter_AnotherSerializationForInt_BinaryInt() { var xsitin = new Person { Name = "xsitin", Age = 19, Height = 185.1, Id = new Guid("dddddddddddddddddddddddddddddddd") }; printer.Printing <int>().Using(x => Convert.ToString(x, 2)); printer.PrintToString(xsitin).Should().Be( string.Join(NewLine + '\t', "Person", "Id = dddddddd-dddd-dddd-dddd-dddddddddddd", "Name = xsitin", "Height = 185.1", "Age = 10011", "OtherPerson = null")); }
public void ObjectPrinter_WithAlternativeSerializationForType_ReturnRightResult() { printer.Printing <string>().Using(s => s.ToUpper()); var result = printer.PrintToString(testPerson); var expectedResult = new StringBuilder() .Append("Person\r\n") .Append("\tId = Guid\r\n") .Append("\tName = PHIL\r\n") .Append("\tHeight = 190\r\n") .Append("\tAge = 22\r\n") .ToString(); result.Should().BeEquivalentTo(expectedResult); }
public void ObjectPrinter_ShouldSerializePropertiesAlternatively() { var expected = string.Join(Environment.NewLine, "MyCustomObject", "\tJustAField = 1337", "\tStringProperty = string (это строковое свойство)", "\tAnotherStringProperty = another string", "\tPerson = Person", "\t\tId = 00000000-0000-0000-0000-000000000000", "\t\tName = John Smith", "\t\tHeight = 13,37", "\t\tAge = 69") + Environment.NewLine; myCustomObjectPrinter.Printing(e => e.StringProperty).Using(e => e + " (это строковое свойство)"); myCustomObjectPrinter.PrintToString(myCustomObject).Should().Be(expected); }
public void SpecializeType_BySelector_ForInt() { var expectedResult = $"Person{newLine} Id = 00000000-0000-0000-0000-000000000000{newLine} Name = Alexander{newLine} Height = 188,9{newLine} Age = int 19{newLine}"; printer .Printing <int>() .Using(num => "int " + num.ToString()) .PrintToString(person) .Should().Be(expectedResult); }
public void PrintToString_ContainsCorrectNumber_WhenThereIsSpecialCulture() { var culture = CultureInfo.GetCultureInfo(10); var printing = printer .Printing <double>() .Using(culture) .PrintToString(person); var numberWithCulture = person.Height.ToString(culture); printing.Should().Contain(numberWithCulture); }
public void AddSerialization_ForType() { printer.Printing <string>().Using(str => '"' + str + '"'); printer.PrintToString(Me).Should() .Contain("Name = \"Natasha\"") .And.Contain("Name = \"Natasha\"") .And.Contain("Surname = \"Smit\""); }
public void ShouldSetPrintingRule_ForTypes() { printingConfig.Printing <double>().Using(x => x.ToString(CultureInfo.InvariantCulture)); printingConfig.Config.TypePrintingRules.Should().ContainKey(typeof(double)); }