@@ -205,7 +205,7 @@ public async Task CanWriteDiskTreeToDisk()
205
205
{
206
206
var flattened = await _synchronizer . LoadoutToFlattenedLoadout ( BaseList . Value ) ;
207
207
var fileTree = await _synchronizer . FlattenedLoadoutToFileTree ( flattened , BaseList . Value ) ;
208
- var prevState = DiskStateRegistry . GetState ( BaseList . Id ) ! ;
208
+ var prevState = DiskStateRegistry . GetState ( BaseList . Value . Installation ) ! ;
209
209
var diskState = await _synchronizer . FileTreeToDisk ( fileTree , BaseList . Value , flattened , prevState , Install ) ;
210
210
211
211
diskState . GetAllDescendentFiles ( )
@@ -323,7 +323,7 @@ public async Task CanIngestFileTree()
323
323
// Reconstruct the previous file tree
324
324
var prevFlattenedLoadout = await _synchronizer . LoadoutToFlattenedLoadout ( BaseList . Value ) ;
325
325
var prevFileTree = await _synchronizer . FlattenedLoadoutToFileTree ( prevFlattenedLoadout , BaseList . Value ) ;
326
- var prevDiskState = DiskStateRegistry . GetState ( BaseList . Id ) ;
326
+ var prevDiskState = DiskStateRegistry . GetState ( BaseList . Value . Installation ) ;
327
327
328
328
var fileTree = await _synchronizer . DiskToFileTree ( diskState , BaseList . Value , prevFileTree , prevDiskState ) ;
329
329
@@ -383,7 +383,7 @@ public async Task CanIngestFlattenedList()
383
383
// Reconstruct the previous file tree
384
384
var prevFlattenedLoadout = await _synchronizer . LoadoutToFlattenedLoadout ( BaseList . Value ) ;
385
385
var prevFileTree = await _synchronizer . FlattenedLoadoutToFileTree ( prevFlattenedLoadout , BaseList . Value ) ;
386
- var prevDiskState = DiskStateRegistry . GetState ( BaseList . Id ) ! ;
386
+ var prevDiskState = DiskStateRegistry . GetState ( BaseList . Value . Installation ) ! ;
387
387
388
388
var fileTree = await _synchronizer . DiskToFileTree ( diskState , BaseList . Value , prevFileTree , prevDiskState ) ;
389
389
var flattenedLoadout = await _synchronizer . FileTreeToFlattenedLoadout ( fileTree , BaseList . Value , prevFlattenedLoadout ) ;
@@ -452,7 +452,7 @@ public async Task CanIngestLoadout()
452
452
// Reconstruct the previous file tree
453
453
var prevFlattenedLoadout = await _synchronizer . LoadoutToFlattenedLoadout ( BaseList . Value ) ;
454
454
var prevFileTree = await _synchronizer . FlattenedLoadoutToFileTree ( prevFlattenedLoadout , BaseList . Value ) ;
455
- var prevDiskState = DiskStateRegistry . GetState ( BaseList . Id ) ! ;
455
+ var prevDiskState = DiskStateRegistry . GetState ( BaseList . Value . Installation ) ! ;
456
456
457
457
var fileTree = await _synchronizer . DiskToFileTree ( diskState , BaseList . Value , prevFileTree , prevDiskState ) ;
458
458
var flattenedLoadout = await _synchronizer . FileTreeToFlattenedLoadout ( fileTree , BaseList . Value , prevFlattenedLoadout ) ;
@@ -652,4 +652,62 @@ public async Task CanWriteGeneratedFiles()
652
652
653
653
}
654
654
655
+ [ Fact ]
656
+ public async Task CanSwitchBetweenLoadouts ( )
657
+ {
658
+ var listA = BaseList ;
659
+ // Apply the old state
660
+ var baseState = await _synchronizer . Apply ( listA . Value ) ;
661
+
662
+ var newId = LoadoutId . NewId ( ) ;
663
+ LoadoutRegistry . Alter ( newId , "Clone List" ,
664
+ _ => listA . Value with {
665
+ LoadoutId = newId ,
666
+ Name = "List B" ,
667
+ } ) ;
668
+ var listB = LoadoutRegistry . GetMarker ( newId ) ;
669
+
670
+ // We have two lists, so we can now swap between them and that's fine because they are the same so far
671
+ await _synchronizer . Apply ( listB . Value ) ;
672
+ await _synchronizer . Apply ( listA . Value ) ;
673
+ await _synchronizer . Apply ( listB . Value ) ;
674
+
675
+ GamePath testFilePath = new ( LocationId . Game , "textures/test_file_switcher.dds" ) ;
676
+
677
+ // Now let's add a mod to listA
678
+ await AddMod ( "Other Files" ,
679
+ // Each mod overrides the same files for these three files
680
+ ( testFilePath . Path , $ "test-file-switcher")
681
+ ) ;
682
+
683
+ listA . Value . Mods . Count . Should ( ) . Be ( listB . Value . Mods . Count + 1 , "the mod should have been added" ) ;
684
+
685
+ var absPath = Install . LocationsRegister . GetResolvedPath ( testFilePath ) ;
686
+ // And apply it
687
+ await _synchronizer . Apply ( listA . Value ) ;
688
+ absPath . FileExists . Should ( ) . BeTrue ( "the file should have been written to disk" ) ;
689
+ ( await absPath . ReadAllTextAsync ( ) ) . Should ( ) . Be ( "test-file-switcher" , "the file should contain the new data" ) ;
690
+
691
+
692
+ // And switch back to listB
693
+ await _synchronizer . Apply ( listB . Value ) ;
694
+
695
+ absPath . FileExists . Should ( ) . BeFalse ( "the file should have been removed from disk" ) ;
696
+
697
+
698
+ var listCValue = await _synchronizer . Manage ( Install ) ;
699
+
700
+ var listC = LoadoutRegistry . GetMarker ( listCValue . LoadoutId ) ;
701
+ await _synchronizer . Ingest ( listC . Value ) ;
702
+
703
+ await _synchronizer . Apply ( listC . Value ) ;
704
+
705
+ await _synchronizer . Apply ( listA . Value ) ;
706
+ await _synchronizer . Apply ( listB . Value ) ;
707
+ await _synchronizer . Apply ( listC . Value ) ;
708
+
709
+
710
+
711
+
712
+ }
655
713
}
0 commit comments