public override void Execute() { var fileMemory = new FileMemory(); // Set the initial state of the originator var file = new File { Author = "John Doe", Content = "", Title = "The mermaid" }; // Save the state fileMemory.AddState(file.CreateState()); FileState initialState = fileMemory.GetLastState(); Assert.Equal(file.Content, initialState.Content); // Change the state of the originator file.Content = "Once upon a time."; Assert.NotEqual(file.Content, initialState.Content); // Restore the state to the previous one. file.RestoreState(initialState); Assert.Equal("", file.Content); }
public async Task SearchMemoryAsync(string input) { List <string> tempMemory = new List <string>(); List <Task> tasksList = new List <Task>(); tasksList.Add(FixedMemoryAsync()); tempMemory.AddRange(FixedMemoryAsync().Result); using (DatabaseMemory db = new DatabaseMemory()) { Task <List <string> > dbtask = db.FindRelatedStringAsync(input); tasksList.Add(dbtask); tempMemory.AddRange(dbtask.Result); } using (FileMemory fm = new FileMemory()) { Task <List <string> > fmtask = fm.FindInFilesAsync(input); tasksList.Add(fmtask); tempMemory.AddRange(fmtask.Result); } await Task.WhenAll(tasksList); _tempMemory = tempMemory; }