public void GetSourceReturnsServerSource() { IServerSource source = new SavedServerSource(new Server("4.3.2.1", 54321)); ServerSelectionItem item = new ServerSelectionItem(source); Assert.AreSame(source, item.GetSource()); }
public void SaveServerAddsServerWithNameWhenSpecified() { ServerSelectionItem item = list.SaveServer(new Server("1.2.3.4", 5678), "SERVER NAME"); Assert.AreEqual(list[2], item); Assert.AreEqual("SERVER NAME (1.2.3.4:5678)", list[2].DisplayName); }
public void SaveServerAddsSavedServerToListAndReturnsItsIndex() { ServerSelectionItem item = list.SaveServer(new Server("1.2.3.4", 5678)); Assert.AreEqual(list[2], item); Assert.AreEqual(3, list.Count); Assert.AreEqual("1.2.3.4:5678", list[2].DisplayName); Assert.IsInstanceOfType(list[2].GetSource(), typeof(SavedServerSource)); }
private void ServerSelectionChanged(object sender, EventArgs e) { removeSelectedServer.Enabled = serverList.IndexRemovable( SelectionCombo.SelectedIndex); ServerSelectionItem item = serverList[SelectionCombo.SelectedIndex]; if (item != null) { serverList.Promote(SelectionCombo.SelectedIndex); UpdateServerSource(item.GetSource()); } }
private void AddProfile_Click(object sender, EventArgs e) { using OpenFileDialog dialog = new OpenFileDialog { Filter = "DayZ Profiles|*_settings.DayZProfile|All files|*.*" }; if (dialog.ShowDialog() == DialogResult.OK) { logger.Debug($"Adding custom profile location: {dialog.FileName}"); ServerSelectionItem item = serverList.SaveProfile(dialog.FileName); SelectionCombo.SelectedItem = item; } }
public void SaveProfileAddsLatestServerSourceForGivenFilenameAndDoesNotChangeSelectedIndex() { comboBox.SelectedIndex = 1; ServerSelectionItem item = list.SaveProfile(@"X:\path\to\some.DayZProfile"); Assert.AreEqual(1, comboBox.SelectedIndex); Assert.AreEqual(3, list.Count); Assert.AreEqual(@"Most Recent (X:\path\to\some.DayZProfile)", list[2].DisplayName); Assert.IsInstanceOfType(list[2].GetSource(), typeof(LatestServerSource)); Assert.AreEqual(list[2], item); }
private async Task <Server> GetSelectedServer() { ServerSelectionItem item = null; if (InvokeRequired) { Invoke(new MethodInvoker(delegate { item = (ServerSelectionItem)SelectionCombo.SelectedItem; })); } else { item = (ServerSelectionItem)SelectionCombo.SelectedItem; } return(await item.GetSource().GetServer()); }
private async Task SaveServer(Server server, string name) { for (int index = SAVED_SERVER_INDEX; index < SelectionCombo.Items.Count; index++) { ServerSelectionItem item = (ServerSelectionItem)SelectionCombo.Items[index]; SavedServerSource source = (SavedServerSource)item.GetSource(); if (server.Equals(await source.GetServer())) { source.ServerName = name; return; } } AddServer(server, name); }
private async Task <Server> GetSelectedServer(CancellationTokenSource source) { ServerSelectionItem item = null; if (InvokeRequired) { Invoke(new MethodInvoker(delegate { item = serverList[SelectionCombo.SelectedIndex]; })); } else { item = serverList[SelectionCombo.SelectedIndex]; } return(await item.GetSource().GetServer(logger, clock, source)); }
public void SaveProfileMovesMatchingServerSourceIfOneAlreadyExistsWithTheSameFilename() { list.SaveProfile(@"X:\path\to\some.DayZProfile"); list.SaveProfile(@"Z:\path\to\some\other.DayZProfile"); comboBox.SelectedIndex = 2; ServerSelectionItem item = list.SaveProfile(@"X:\path\to\some.DayZProfile"); Assert.AreEqual(3, comboBox.SelectedIndex); Assert.AreEqual(4, list.Count); Assert.AreEqual(@"Most Recent (X:\path\to\some.DayZProfile)", list[2].DisplayName); Assert.IsInstanceOfType(list[2].GetSource(), typeof(LatestServerSource)); Assert.AreEqual(@"Most Recent (Z:\path\to\some\other.DayZProfile)", list[3].DisplayName); Assert.IsInstanceOfType(list[3].GetSource(), typeof(LatestServerSource)); Assert.AreEqual(list[2], item); }
public void PromoteMovesItemToTheTopOfTheListAndDoesNotChangeTheSelectedItem() { list.SaveServer(new Server("1.2.3.4", 5678), "SAVED FIRST"); list.SaveProfile(@"X:\path\to\some.DayZProfile"); list.SaveServer(new Server("5.6.7.8", 4321), "SAVED SECOND"); comboBox.SelectedIndex = 2; ServerSelectionItem item = list.Promote(3); Assert.AreEqual(3, comboBox.SelectedIndex); Assert.AreEqual(5, list.Count); Assert.AreEqual("Most Recent (Stable)", list[0].DisplayName); Assert.AreEqual("Most Recent (Experimental)", list[1].DisplayName); Assert.AreEqual(@"Most Recent (X:\path\to\some.DayZProfile)", list[2].DisplayName); Assert.AreEqual("SAVED SECOND (5.6.7.8:4321)", list[3].DisplayName); Assert.AreEqual("SAVED FIRST (1.2.3.4:5678)", list[4].DisplayName); Assert.AreEqual(list[2], item); }
private void AddServer_Click(object sender, EventArgs e) { using AddServerDialog dialog = new AddServerDialog { TopMost = settings.AlwaysOnTop }; if (dialog.ShowDialog() == DialogResult.OK) { try { logger.Debug($"Adding server: {dialog.IPAddress}:{dialog.Port}"); ServerSelectionItem item = serverList.SaveServer(new Server(dialog.IPAddress, dialog.Port)); SelectionCombo.SelectedItem = item; } catch (Exception error) { logger.Error("Failed to add server", error); } } }
private void ServerSelectionChanged(object sender, EventArgs e) { ServerSelectionItem item = (ServerSelectionItem)SelectionCombo.SelectedItem; UpdateServerSource(item.GetSource()); }
public void DisplayNameContainsServerSourceDisplayName() { ServerSelectionItem item = new ServerSelectionItem(new SavedServerSource(new Server("4.3.2.1", 54321))); Assert.AreEqual("4.3.2.1:54321", item.DisplayName); }
public void ValueContainsSelf() { ServerSelectionItem item = new ServerSelectionItem(new SavedServerSource(new Server("4.3.2.1", 54321))); Assert.AreSame(item, item.Value); }