public void TestModified() { List <Substitution> existingSubstitutions = CreateExistingSubstitutions(); List <Substitution> newSubstitutions = CreateNewSubstitutions(); // when var modifiedSubstitutions = SubstitutionsComparator.FindModifiedSubstitutions(existingSubstitutions, newSubstitutions); // then Assert.Equal(1, modifiedSubstitutions.Count()); Assert.Contains(newSubstitutions[1], modifiedSubstitutions); }
public async Task saveFileAsync(Substitutions newSubstitutions, string path) { Console.WriteLine("Writing Mac"); using (var connection = GetConnection(path)) { await connection.OpenAsync(); var existingSubstitutions = await loadSubstitutionsFromConnection(connection); var addedSubs = SubstitutionsComparator.FindAddedSubstitutions(existingSubstitutions, newSubstitutions.substitutions); var deletedSubs = SubstitutionsComparator.FindDeletedSubstitutions(existingSubstitutions, newSubstitutions.substitutions); var modifiedSubs = SubstitutionsComparator.FindModifiedSubstitutions(existingSubstitutions, newSubstitutions.substitutions); addedSubs.ToList().ForEach(async addedSub => await this.addSubstitutionToConnection(connection, addedSub)); deletedSubs.ToList().ForEach(async deletedSub => await this.removeSubstitutionToConnection(connection, deletedSub)); modifiedSubs.ToList().ForEach(async modifiedSub => await this.updateSubstitutionToConnection(connection, modifiedSub)); } }