public static ClusterConfiguration LoadFromEmbeddedResource(this ClusterConfiguration config, Assembly assembly, string fullResourcePath) { var result = new ClusterConfiguration(); result.Load(assembly.LoadEmbeddedResource(fullResourcePath)); return(result); }
public void Config_NewConfigTest() { TextReader input = File.OpenText("Config_TestSiloConfig.xml"); ClusterConfiguration config = new ClusterConfiguration(); config.Load(input); input.Close(); Assert.Equal <int>(2, config.Globals.SeedNodes.Count); // Seed node count is incorrect Assert.Equal <IPEndPoint>(new IPEndPoint(IPAddress.Loopback, 11111), config.Globals.SeedNodes[0]); // First seed node is set incorrectly Assert.Equal <IPEndPoint>(new IPEndPoint(IPAddress.IPv6Loopback, 22222), config.Globals.SeedNodes[1]); // Second seed node is set incorrectly Assert.Equal <int>(12345, config.Defaults.Port); // Default port is set incorrectly Assert.Equal("UnitTests.General.TestStartup,Tester", config.Defaults.StartupTypeName); NodeConfiguration nc; bool hasNodeConfig = config.TryGetNodeConfigurationForSilo("Node1", out nc); Assert.True(hasNodeConfig); // Node Node1 has config Assert.Equal <int>(11111, nc.Port); // Port is set incorrectly for node Node1 Assert.True(nc.IsPrimaryNode, "Node1 should be primary node"); Assert.True(nc.IsSeedNode, "Node1 should be seed node"); Assert.False(nc.IsGatewayNode, "Node1 should not be gateway node"); Assert.Equal("UnitTests.General.TestStartup,Tester", nc.StartupTypeName); // Startup type should be copied automatically hasNodeConfig = config.TryGetNodeConfigurationForSilo("Node2", out nc); Assert.True(hasNodeConfig, "Node Node2 has config"); Assert.Equal <int>(22222, nc.Port); // Port is set incorrectly for node Node2 Assert.False(nc.IsPrimaryNode, "Node2 should not be primary node"); Assert.True(nc.IsSeedNode, "Node2 should be seed node"); Assert.True(nc.IsGatewayNode, "Node2 should be gateway node"); hasNodeConfig = config.TryGetNodeConfigurationForSilo("Store", out nc); Assert.True(hasNodeConfig, "Node Store has config"); Assert.Equal <int>(12345, nc.Port); // IP port is set incorrectly for node Store Assert.False(nc.IsPrimaryNode, "Store should not be primary node"); Assert.False(nc.IsSeedNode, "Store should not be seed node"); Assert.False(nc.IsGatewayNode, "Store should not be gateway node"); //IPAddress[] ips = Dns.GetHostAddresses(""); //IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 12345); //for (int i = 0; i < ips.Length; i++) //{ // if ((ips[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) && !IPAddress.Loopback.Equals(ips[i])) // { // ep = new IPEndPoint(ips[i], 12345); // break; // } //} //Assert.Equal<IPEndPoint>(ep, nc.Endpoint, "IP endpoint is set incorrectly for node Store"); }