public void TestAddListener() { // GIVEN an empty config builder DarkRiftServerConfigurationBuilder builder = DarkRiftServerConfigurationBuilder.Create(); // WHEN a listener is added builder.AddListener("name", "type", IPAddress.Broadcast, 1234); // THEN the listener is added to the spawn data Assert.AreEqual(1, builder.ServerSpawnData.Listeners.NetworkListeners.Count); Assert.AreEqual("name", builder.ServerSpawnData.Listeners.NetworkListeners[0].Name); Assert.AreEqual("type", builder.ServerSpawnData.Listeners.NetworkListeners[0].Type); Assert.AreEqual(IPAddress.Broadcast, builder.ServerSpawnData.Listeners.NetworkListeners[0].Address); Assert.AreEqual(1234, builder.ServerSpawnData.Listeners.NetworkListeners[0].Port); Assert.AreEqual(0, builder.ServerSpawnData.Listeners.NetworkListeners[0].Settings.Count); }
public void TestAddListenerWithSettings() { // GIVEN an empty config builder DarkRiftServerConfigurationBuilder builder = DarkRiftServerConfigurationBuilder.Create(); // WHEN a listener is added NameValueCollection settings = new NameValueCollection() { { "key", "value" } }; builder.AddListener("name", "type", IPAddress.Broadcast, 1234, settings); // THEN the listener is added to the spawn data Assert.AreEqual(1, builder.ServerSpawnData.Listeners.NetworkListeners.Count); Assert.AreEqual("name", builder.ServerSpawnData.Listeners.NetworkListeners[0].Name); Assert.AreEqual("type", builder.ServerSpawnData.Listeners.NetworkListeners[0].Type); Assert.AreEqual(IPAddress.Broadcast, builder.ServerSpawnData.Listeners.NetworkListeners[0].Address); Assert.AreEqual(1234, builder.ServerSpawnData.Listeners.NetworkListeners[0].Port); Assert.AreEqual(1, builder.ServerSpawnData.Listeners.NetworkListeners[0].Settings.Count); Assert.AreEqual("value", builder.ServerSpawnData.Listeners.NetworkListeners[0].Settings["key"]); }