public void ServerTest() { Server srv; srv = new InstituteAccessServer(); srv.Load(new Dictionary <string, object> { { "base_url", "https://surf.eduvpn.nl/" } }); Assert.AreEqual(new Uri("https://surf.eduvpn.nl/"), srv.Base, "Base URI incorrect"); Assert.AreEqual("surf.eduvpn.nl", srv.ToString(), "Display name incorrect"); srv = new InstituteAccessServer(); srv.Load(new Dictionary <string, object> { { "base_url", "https://surf.eduvpn.nl/" }, { "display_name", "SURF" } }); Assert.AreEqual(new Uri("https://surf.eduvpn.nl/"), srv.Base, "Base URI incorrect"); Assert.AreEqual("SURF", srv.ToString(), "Display name incorrect"); srv = new SecureInternetServer(); srv.Load(new Dictionary <string, object> { { "base_url", "https://surf.eduvpn.nl/" }, { "country_code", "NL" }, { "support_contact", new List <object>() { "mailto:[email protected]" } }, }); Assert.AreEqual(new Uri("https://surf.eduvpn.nl/"), srv.Base, "Base URI incorrect"); Assert.AreEqual(new Country("NL").ToString(), srv.ToString(), "Display name incorrect"); Assert.AreEqual("NL", ((SecureInternetServer)srv).Country.Code, "Country code incorrect"); // Test issues. Assert.ThrowsException <eduJSON.MissingParameterException>(() => { srv = new InstituteAccessServer(); srv.Load(new Dictionary <string, object> { { "display_name", "SURF" }, }); }); Assert.ThrowsException <eduJSON.MissingParameterException>(() => { srv = new SecureInternetServer(); srv.Load(new Dictionary <string, object> { { "display_name", "SURF" }, }); }); }
/// <summary> /// Adds institute access server to the list /// </summary> /// <param name="srv">Server</param> public void AddInstituteAccessServer(InstituteAccessServer srv) { if (Properties.Settings.Default.InstituteAccessServers.Contains(srv.Base)) { return; } Properties.Settings.Default.InstituteAccessServers.Add(srv.Base); srv = Wizard.GetDiscoveredServer <InstituteAccessServer>(srv.Base); if (srv != null) { InstituteAccessServers.Add(srv); } }