@@ -11,14 +11,13 @@ public MigrationManagerTests()
1111 }
1212
1313 [ Fact ]
14- public async Task Should_Migrate_From_8_To_12 ( )
14+ public async Task Should_Migrate_From_11_To_12 ( )
1515 {
1616 // Arrange
17- var testFile = Path . Combine ( _testDirectory , "appsettings.json" ) ;
17+ var testFile = Path . Combine ( _testDirectory , "appsettings.Development. json" ) ;
1818 var json = """
1919 {
20- "BlogName": "Test Blog",
21- "KofiToken": "test123"
20+ "BlogName": "Test Blog"
2221 }
2322 """ ;
2423 await File . WriteAllTextAsync ( testFile , json ) ;
@@ -32,8 +31,6 @@ public async Task Should_Migrate_From_8_To_12()
3231 result . ShouldBeTrue ( ) ;
3332 var content = await File . ReadAllTextAsync ( testFile ) ;
3433 content . ShouldContain ( "\" ConfigVersion\" : \" 12.0\" " ) ;
35- content . ShouldContain ( "\" SupportMe\" " ) ;
36- content . ShouldContain ( "\" UseMultiAuthorMode\" : false" ) ;
3734 content . ShouldContain ( "\" ShowBuildInformation\" : true" ) ;
3835
3936 // Verify backup was created
@@ -45,14 +42,12 @@ public async Task Should_Migrate_From_8_To_12()
4542 public async Task Should_Not_Modify_Already_Migrated_File ( )
4643 {
4744 // Arrange
48- var testFile = Path . Combine ( _testDirectory , "appsettings.json" ) ;
45+ var testFile = Path . Combine ( _testDirectory , "appsettings.Production. json" ) ;
4946 var json = """
5047 {
5148 "ConfigVersion": "12.0",
5249 "BlogName": "Test Blog",
53- "ShowBuildInformation": true,
54- "UseMultiAuthorMode": false,
55- "ShowSimilarPosts": false
50+ "ShowBuildInformation": true
5651 }
5752 """ ;
5853 await File . WriteAllTextAsync ( testFile , json ) ;
@@ -69,26 +64,35 @@ public async Task Should_Not_Modify_Already_Migrated_File()
6964 }
7065
7166 [ Fact ]
72- public async Task Should_Handle_Invalid_Json ( )
67+ public async Task Should_Skip_Version_Controlled_Appsettings_Json ( )
7368 {
7469 // Arrange
75- var testFile = Path . Combine ( _testDirectory , "invalid.json" ) ;
76- await File . WriteAllTextAsync ( testFile , "{ invalid json }" ) ;
70+ var testFile = Path . Combine ( _testDirectory , "appsettings.json" ) ;
71+ var json = """
72+ {
73+ "BlogName": "Test Blog"
74+ }
75+ """ ;
76+ await File . WriteAllTextAsync ( testFile , json ) ;
7777 var manager = new MigrationManager ( ) ;
7878 var backupDir = Path . Combine ( _testDirectory , "backups" ) ;
7979
8080 // Act
8181 var result = await manager . MigrateFileAsync ( testFile , false , backupDir ) ;
8282
8383 // Assert
84- result . ShouldBeFalse ( ) ;
84+ result . ShouldBeTrue ( ) ;
85+ var content = await File . ReadAllTextAsync ( testFile ) ;
86+ content . ShouldBe ( json ) ; // Should not change
87+ Directory . Exists ( backupDir ) . ShouldBeFalse ( ) ; // No backup created
8588 }
8689
8790 [ Fact ]
88- public async Task Should_Handle_Missing_File ( )
91+ public async Task Should_Handle_Invalid_Json ( )
8992 {
9093 // Arrange
91- var testFile = Path . Combine ( _testDirectory , "nonexistent.json" ) ;
94+ var testFile = Path . Combine ( _testDirectory , "appsettings.Invalid.json" ) ;
95+ await File . WriteAllTextAsync ( testFile , "{ invalid json }" ) ;
9296 var manager = new MigrationManager ( ) ;
9397 var backupDir = Path . Combine ( _testDirectory , "backups" ) ;
9498
@@ -100,40 +104,27 @@ public async Task Should_Handle_Missing_File()
100104 }
101105
102106 [ Fact ]
103- public async Task DryRun_Should_Not_Modify_File ( )
107+ public async Task Should_Handle_Missing_File ( )
104108 {
105109 // Arrange
106- var testFile = Path . Combine ( _testDirectory , "appsettings.json" ) ;
107- var json = """
108- {
109- "BlogName": "Test Blog",
110- "KofiToken": "test123"
111- }
112- """ ;
113- await File . WriteAllTextAsync ( testFile , json ) ;
110+ var testFile = Path . Combine ( _testDirectory , "nonexistent.json" ) ;
114111 var manager = new MigrationManager ( ) ;
115112 var backupDir = Path . Combine ( _testDirectory , "backups" ) ;
116113
117114 // Act
118- var result = await manager . MigrateFileAsync ( testFile , true , backupDir ) ;
115+ var result = await manager . MigrateFileAsync ( testFile , false , backupDir ) ;
119116
120117 // Assert
121- result . ShouldBeTrue ( ) ;
122- var content = await File . ReadAllTextAsync ( testFile ) ;
123- content . ShouldBe ( json ) ; // Should not change in dry-run mode
124-
125- // Verify no backup was created in dry-run mode
126- Directory . Exists ( backupDir ) . ShouldBeFalse ( ) ;
118+ result . ShouldBeFalse ( ) ;
127119 }
128120
129121 [ Fact ]
130- public async Task Should_Apply_Partial_Migrations ( )
122+ public async Task DryRun_Should_Not_Modify_File ( )
131123 {
132124 // Arrange
133- var testFile = Path . Combine ( _testDirectory , "appsettings.json" ) ;
125+ var testFile = Path . Combine ( _testDirectory , "appsettings.Development. json" ) ;
134126 var json = """
135127 {
136- "ConfigVersion": "9.0",
137128 "BlogName": "Test Blog"
138129 }
139130 """ ;
@@ -142,15 +133,15 @@ public async Task Should_Apply_Partial_Migrations()
142133 var backupDir = Path . Combine ( _testDirectory , "backups" ) ;
143134
144135 // Act
145- var result = await manager . MigrateFileAsync ( testFile , false , backupDir ) ;
136+ var result = await manager . MigrateFileAsync ( testFile , true , backupDir ) ;
146137
147138 // Assert
148139 result . ShouldBeTrue ( ) ;
149140 var content = await File . ReadAllTextAsync ( testFile ) ;
150- content . ShouldContain ( " \" ConfigVersion \" : \" 12.0 \" " ) ;
151- content . ShouldContain ( " \" UseMultiAuthorMode \" : false" ) ;
152- content . ShouldContain ( " \" ShowBuildInformation \" : true" ) ;
153- content . ShouldNotContain ( " \" SupportMe \" " ) ; // Should not apply 8.0->9.0 migration
141+ content . ShouldBe ( json ) ; // Should not change in dry-run mode
142+
143+ // Verify no backup was created in dry-run mode
144+ Directory . Exists ( backupDir ) . ShouldBeFalse ( ) ;
154145 }
155146
156147 public void Dispose ( )
0 commit comments