@@ -7,62 +7,40 @@ namespace FluentAssertions.Json.Specs
77 // ReSharper disable InconsistentNaming
88 public class JTokenFormatterSpecs
99 {
10+ public JTokenFormatterSpecs ( )
11+ {
12+ Formatter . AddFormatter ( new JTokenFormatter ( ) ) ;
13+ }
14+
1015 [ Fact ]
1116 public void Should_Handle_JToken ( )
1217 {
1318 //-----------------------------------------------------------------------------------------------------------
14- // Arrange
15- //-----------------------------------------------------------------------------------------------------------
16- var sut = new JTokenFormatter ( ) ;
17-
19+ // Act / Arrange
1820 //-----------------------------------------------------------------------------------------------------------
19- // Act
20- //-----------------------------------------------------------------------------------------------------------
21- var actual = sut . CanHandle ( JToken . Parse ( "{}" ) ) ;
21+ var actual = Formatter . ToString ( JToken . Parse ( "{}" ) ) ;
2222
2323 //-----------------------------------------------------------------------------------------------------------
2424 // Assert
2525 //-----------------------------------------------------------------------------------------------------------
26- actual . Should ( ) . BeTrue ( ) ;
26+ actual . Should ( ) . Be ( "{}" ) ;
2727 }
2828
29- [ Fact ]
30- public void Should_not_handle_anything_else ( )
31- {
32- //-----------------------------------------------------------------------------------------------------------
33- // Arrange
34- //-----------------------------------------------------------------------------------------------------------
35- var testCases = new object [ ] { null , string . Empty } ;
36- var sut = new JTokenFormatter ( ) ;
37-
38- foreach ( var testCase in testCases )
39- {
40- //-----------------------------------------------------------------------------------------------------------
41- // Act
42- //-----------------------------------------------------------------------------------------------------------
43- var actual = sut . CanHandle ( testCase ) ;
44-
45- //-----------------------------------------------------------------------------------------------------------
46- // Assert
47- //-----------------------------------------------------------------------------------------------------------
48- actual . Should ( ) . BeFalse ( ) ;
49- }
50- }
51-
52-
5329 [ Fact ]
5430 public void Should_preserve_indenting ( )
5531 {
5632 //-----------------------------------------------------------------------------------------------------------
5733 // Arrange
5834 //-----------------------------------------------------------------------------------------------------------
5935 var json = JToken . Parse ( "{ \" id\" :1 }" ) ;
60- var sut = new JTokenFormatter ( ) ;
6136
6237 //-----------------------------------------------------------------------------------------------------------
6338 // Act
6439 //-----------------------------------------------------------------------------------------------------------
65- var actual = sut . Format ( json , new FormattingContext { UseLineBreaks = true } , ( path , value ) => "" ) ;
40+ var actual = Formatter . ToString ( json , new FormattingOptions
41+ {
42+ UseLineBreaks = true
43+ } ) ;
6644
6745 //-----------------------------------------------------------------------------------------------------------
6846 // Assert
@@ -77,13 +55,15 @@ public void Should_Remove_line_breaks_and_indenting()
7755 // Arrange
7856 //-----------------------------------------------------------------------------------------------------------
7957 var json = JToken . Parse ( "{ \" id\" :1 }" ) ;
80- var sut = new JTokenFormatter ( ) ;
8158
8259 //-----------------------------------------------------------------------------------------------------------
8360 // Act
8461 //-----------------------------------------------------------------------------------------------------------
8562 // ReSharper disable once RedundantArgumentDefaultValue
86- var actual = sut . Format ( json , new FormattingContext { UseLineBreaks = false } , ( path , value ) => "" ) ;
63+ var actual = Formatter . ToString ( json , new FormattingOptions
64+ {
65+ UseLineBreaks = false
66+ } ) ;
8767
8868 //-----------------------------------------------------------------------------------------------------------
8969 // Assert
0 commit comments