コード例 #1
0
        public void GetSourceReturnsServerSource()
        {
            IServerSource       source = new SavedServerSource(new Server("4.3.2.1", 54321));
            ServerSelectionItem item   = new ServerSelectionItem(source);

            Assert.AreSame(source, item.GetSource());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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());
            }
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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());
        }
コード例 #8
0
 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);
 }
コード例 #9
0
        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));
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 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);
         }
     }
 }
コード例 #13
0
        private void ServerSelectionChanged(object sender, EventArgs e)
        {
            ServerSelectionItem item = (ServerSelectionItem)SelectionCombo.SelectedItem;

            UpdateServerSource(item.GetSource());
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        public void ValueContainsSelf()
        {
            ServerSelectionItem item = new ServerSelectionItem(new SavedServerSource(new Server("4.3.2.1", 54321)));

            Assert.AreSame(item, item.Value);
        }