public void Test4() { IHistoryManager<int> h = new HistoryManager<int>(1); h.Add(2); h.Undo(); h.Add(3); Assert.False(h.CanRedo()); }
private void NetInfoWindow_Load(object sender, EventArgs e) { _floatHistory.Add("up"); _floatHistory.Add("down"); plotter1.Data1 = FloatHistory["up"]; plotter1.Data2 = FloatHistory["down"]; this._monitor = new NetworkMonitor(); this._monitor.StopMonitoring(); this._monitor.StartMonitoring(); }
public void Play(Track track) { CurrentPlaylist.Current = track; MediaPlayer.Open(track.GetUri(Context)); HistoryManager.Add(track.Model); Resume(); }
/// <summary>Open the project file.</summary> /// <param name="path">The file path.</param> private void OpenFile(string path) { UpdatePackage(new Package(path)); try { using (StreamReader _streamReader = new StreamReader(path)) { string _line = _streamReader.ReadToEnd(); ControlPanel.FileSaved = true; ControlPanel.FileName = Path.GetFileName(path); ControlPanel.FullPath = path; _historyManager.Add(path); _historyManager.UpdateMenu(); _historyManager.Save(); tabControlMain.TabPages[1].Text = ControlPanel.FileName; } } catch (Exception e) { Console.WriteLine(e); } }
private void Go_Click(object sender, RoutedEventArgs e) { try { Output.Document.Blocks.Clear(); Curl curl = new Curl(); curl.Method = Method.Text; curl.Url = Url.Text; curl.Body = Body.Text; curl.Headers = Headers; curl.JsonContent = ChkJson.IsChecked.HasValue ? ChkJson.IsChecked.Value : false; curl.AcceptSelfSignedCerts = ChkSelfSigne.IsChecked.HasValue ? ChkSelfSigne.IsChecked.Value : false; curl.Verbose = ChkVerbose.IsChecked.HasValue ? ChkVerbose.IsChecked.Value : false; curl.Run(); HistoryManager.Add(Url.Text); Output.AppendText(curl.Output); } catch (Exception ex) { MessageBox.Show(this, ex.Message, ":(", MessageBoxButton.OK, MessageBoxImage.Error); } }
static void Main(string[] args) { HistoryManager hm = new HistoryManager(); Console.WriteLine(hm.GetHistory()); try { hm.Add(""); } catch (Exception e) { Console.WriteLine(e.Message); } try { hm.Add(null); } catch (Exception e) { Console.WriteLine(e.Message); } try { hm.Add("23+54"); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine(GetArrayAsString(hm.HistoryList)); Console.WriteLine(); Console.WriteLine(hm.GetHistory(0)); Console.WriteLine(); hm.Add("9*294"); Console.WriteLine(hm.GetHistory()); Console.Read(); hm.SaveHistory(); }
public void Test3() { IHistoryManager<int> h = new HistoryManager<int>(); Assert.Throws<ApplicationException>(delegate { h.Undo(); }); Assert.Throws<ApplicationException>(delegate { h.Redo(); }); h.Add(1); Assert.Throws<ApplicationException>(delegate { h.Undo(); }); Assert.Throws<ApplicationException>(delegate { h.Redo(); }); }
public PlotterIcon() { _floatHistory.Add(true); _floatHistory.Add(false); _longHistory.Add(true); _longHistory.Add(false); _plotter = new Plotter() { Size = this.Size, ShowGrid = false, BackColor = Color.Black, MoveStep = 2, Data1 = _floatHistory[true], Data2 = _floatHistory[false], LongData1 = _longHistory[true], LongData2 = _longHistory[false] }; }
public void TestAddDuplicateLine() { string filepath = Path.GetTempFileName(); List <string> expectedHistory = mockHistory.ToList(); expectedHistory.Add("ls -al"); var hm = new HistoryManager(filepath); hm.Start().Wait(); mockHistory.ForEach(s => hm.Add(s)); hm.Add("ls -al"); IEnumerable <string> actualHistory = hm.GetHistory(); IEnumerable <string> fileHistory = hm.GetFileHistory(); actualHistory.Should().BeEquivalentTo(expectedHistory, options => options.WithStrictOrdering()); fileHistory.Should().BeEquivalentTo(expectedHistory, options => options.WithStrictOrdering()); File.Delete(filepath); }
public bool ShowText(string clientId, string content) { var client = DataManager.GetList <ClientWindow>().FirstOrDefault(e => e.ID == clientId); LEDAdapterManager.LEDAdapter.SetFont(new Font(client.FontFamily, client.FontSize), (ContentAlignment)client.TextAlignment, 0, client.LEDVirtualID); //持续时间、编号类型 LEDAdapterManager.LEDAdapter.SendContent(content, (int)client.TextAnimation, 10, client.LEDVirtualID); Console.WriteLine(content); HistoryManager.Add(new History { ClientId = clientId, Content = content }); return(true); }
public void TestNewLineSavedToFile() { string filepath = Path.GetTempFileName(); var hm = new HistoryManager(filepath); hm.Start().Wait(); hm.Add("newcommand"); IEnumerable <string> actualHistory = hm.GetHistory(); IEnumerable <string> fileHistory = hm.GetFileHistory(); actualHistory.Should().BeEquivalentTo(new List <string> { "newcommand" }); fileHistory.Should().BeEquivalentTo(new List <string> { "newcommand" }); File.Delete(filepath); }
public void TestAddUniqueLine() { string filepath = Path.GetTempFileName(); List <string> expectedHistory = mockHistory.ToList(); expectedHistory.Add("newcommand"); using (TextWriter tw = new StreamWriter(filepath)) { mockHistory.ForEach(s => tw.WriteLine(s)); } var hm = new HistoryManager(filepath); hm.Start().Wait(); hm.Add("newcommand"); IEnumerable <string> actualHistory = hm.GetHistory(); IEnumerable <string> fileHistory = hm.GetFileHistory(); actualHistory.Should().BeEquivalentTo(expectedHistory); fileHistory.Should().BeEquivalentTo(expectedHistory); File.Delete(filepath); }
public void TestMultilineLine() { string filepath = Path.GetTempFileName(); List <string> expectedHistory = new List <string> { "echo \"line 1\\n line 2\\n line 3\"", "echo \"line 4\\n line 5\"" }; using (TextWriter tw = new StreamWriter(filepath)) { tw.WriteLine("echo \"line 1\\n line 2\\n line 3\""); } var hm = new HistoryManager(filepath); hm.Start().Wait(); hm.Add("echo \"line 4\n line 5\""); IEnumerable <string> actualHistory = hm.GetHistory(); IEnumerable <string> fileHistory = hm.GetFileHistory(); actualHistory.Should().BeEquivalentTo(expectedHistory, options => options.WithStrictOrdering()); fileHistory.Should().BeEquivalentTo(expectedHistory, options => options.WithStrictOrdering()); File.Delete(filepath); }