mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 15:02:15 +01:00
fix(settings): an imported ini moved to the trains' tapes too, a closed tape window forgets only its own tape
- ImportFrom moves an ini of before the trains' tapes as a profile is - HaslerTapes.Forget takes the file: a window closing lets go of its own tape, not of the one another window follows
This commit is contained in:
@@ -182,6 +182,26 @@ public class HaslerTapeTests
|
||||
Assert.Equal(18, Assert.Single(tapes.Load(file, follow: true)!.Samples).SpeedKmh, 6);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Forgetting_another_file_keeps_the_followed_tape_and_its_own_lets_it_go()
|
||||
{
|
||||
string Lines(int firstSpeed, int count) =>
|
||||
Header + Line(0, firstSpeed, 0, 0) + string.Concat(Enumerable.Range(1, count).Select(t => Line(t, 36, 0, 0)));
|
||||
string path = TestInstallation.At("physicslog", "EU07-424.dat");
|
||||
var files = new InMemoryFileSystem().WithFile(path, Lines(36, 20));
|
||||
var tapes = new TestInstallation(files).Tapes;
|
||||
var file = Assert.Single(tapes.List());
|
||||
tapes.Load(file, follow: false);
|
||||
|
||||
// the first line changed, as long as it was and far from the end: a tape still followed doesn't read it again
|
||||
files.WithFile(path, Lines(72, 21));
|
||||
tapes.Forget(TestInstallation.At("physicslog", "EU07-111.dat"));
|
||||
Assert.Equal(36, tapes.Load(file, follow: true)!.Samples[0].SpeedKmh, 6);
|
||||
|
||||
tapes.Forget(file.Path);
|
||||
Assert.Equal(72, tapes.Load(file, follow: true)!.Samples[0].SpeedKmh, 6);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_sample_under_a_point_of_the_tape_is_found_by_time_and_by_distance()
|
||||
{
|
||||
|
||||
@@ -1436,6 +1436,24 @@ public class SettingsStoreTests
|
||||
Assert.False(installation.SettingsStore.Settings.PhysicsLogTrains);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_imported_ini_from_before_the_tapes_of_the_trains_is_moved_as_a_profile_is()
|
||||
{
|
||||
string backup = Path.Combine("/home/kolejarz", "backup", "eu07.ini");
|
||||
var files = new InMemoryFileSystem()
|
||||
.WithFile(UserIni, "physicslog yes\nphysicslog.trains no\n")
|
||||
.WithFile(backup, "physicslog yes\nblackbox yes\n");
|
||||
var store = WithHome(files).SettingsStore;
|
||||
store.Load();
|
||||
|
||||
Assert.True(store.ImportFrom(backup));
|
||||
store.Save();
|
||||
|
||||
Assert.False(store.Settings.PhysicsLog);
|
||||
Assert.True(store.Settings.PhysicsLogTrains);
|
||||
Assert.Contains("physicslog.trains yes", files.ReadAllText(UserIni, System.Text.Encoding.UTF8));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Once_moved_the_physics_log_of_every_vehicle_turned_on_again_stays_on()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user