public void TestConstructorSetsPropertiesCorrectly() { XboxConfigurationSetting <int> setting = new XboxConfigurationSetting <int>(CorrectKey); Assert.AreEqual(CorrectKey, setting.Key, "The Key property was not set correctly."); Assert.IsNull(setting.StringValue, "The StringValue property was not set to null."); Assert.AreEqual(default(int), setting.Value, "The Value property was not set to the default value."); }
private void TestSetting <T>(XboxConfigurationSetting <T> setting, string key) { Assert.IsNotNull(setting, "The setting {0} is null.", key); Assert.AreEqual(setting.Key, key, "The setting has key {1} while the key {0} is expected.", key, setting.Key); Assert.IsNull(setting.StringValue, "The StringValue property of setting {0} is not set to null."); Assert.IsNotNull(setting.GetType().GetProperty("Value", BindingFlags.NonPublic | BindingFlags.Instance), "The non-public instance Value property of setting {0} does not exist.", key); Assert.AreEqual(setting.GetType().GetProperty("Value", BindingFlags.NonPublic | BindingFlags.Instance).PropertyType, typeof(T), "The Value property of setting {0} is not an instance of {1} type.", key, typeof(T).Name); Assert.AreEqual(setting.Value, default(T), "The Value property of setting {0} is not set to the default value."); }
private void TestValueProperty <T>(string correctStringValue, T correctValue) { XboxConfigurationSetting <T> setting = new XboxConfigurationSetting <T>(CorrectKey); setting.Value = correctValue; Assert.AreEqual(correctValue, setting.Value, "The Value property was not set correctly."); Assert.AreEqual(correctStringValue, setting.StringValue, "The StringValue property was not set correctly."); }