public async Task ReplaceAndSave() { string url = $@"{AppDomain.CurrentDomain.BaseDirectory}Tools\Replacer\Templates\TextFile.txt"; FileReplacer fileReplacer = new FileReplacer(url); List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >(3) { new KeyValuePair <string, string>(@"{{Name}}", @"Israel Chavezz"), new KeyValuePair <string, string>(@"{{Age}}", @"27"), new KeyValuePair <string, string>(@"{{Email}}", @"*****@*****.**"), }; string urlCopy = $@"{AppDomain.CurrentDomain.BaseDirectory}TestResults\Tools\Replacer\TextFile.txt"; Assert.True(await fileReplacer.ReplaceAndSave(values, urlCopy)); }
public async Task ReplaceKeys() { string url = $@"{AppDomain.CurrentDomain.BaseDirectory}Tools\Replacer\Templates\TextFile.txt"; FileReplacer fileReplacer = new FileReplacer(url); List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >(3) { new KeyValuePair <string, string>(@"{{Name}}", @"Israel Chavezz"), new KeyValuePair <string, string>(@"{{Age}}", @"27"), new KeyValuePair <string, string>(@"{{Email}}", @"*****@*****.**"), }; await fileReplacer.ReplaceKeys(values); List <string> keys = values .Select(v => v.Key) .ToList(); Assert.True(keys.TrueForAll(k => !fileReplacer.Content.Contains(k))); }