public void FillEmptyTest() { // create a config item var emptyConfig = new RuntimeConfigManagerTestConfig1(); // check if all system default values are not the same like the configured default values. Assert.False(emptyConfig.NullableBooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Nullable Boolean: The system default value equals the test setup default value."); Assert.False(emptyConfig.BooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Boolean: The system default value equals the test setup default value."); Assert.False(emptyConfig.ByteField == RuntimeConfigManagerTestConfig1.ByteFieldDefault, "Byte: The system default value equals the test setup default value."); Assert.False(emptyConfig.DoubleField.CompareTo(RuntimeConfigManagerTestConfig1.DoubleFieldDefault) == 0, "Double: The system default value equals the test setup default value."); Assert.False(emptyConfig.EnumField == RuntimeConfigManagerTestConfig1.EnumFieldDefault, "Enum: The system default value equals the test setup default value."); Assert.False(emptyConfig.IntField == RuntimeConfigManagerTestConfig1.IntFieldDefault, "Integer: The system default value equals the test setup default value."); Assert.False(emptyConfig.LongField == RuntimeConfigManagerTestConfig1.LongFieldDefault, "Long: The system default value equals the test setup default value."); Assert.False(emptyConfig.StringField == RuntimeConfigManagerTestConfig1.StringFieldDefault, "String: The system default value equals the test setup default value."); // load the default values for unset properties _manager.FillEmpty(emptyConfig); // check if all properties got their default values. Assert.True(emptyConfig.BooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Boolean field has been initialized!"); Assert.True(emptyConfig.EnumField == RuntimeConfigManagerTestConfig1.EnumFieldDefault, "Enum field has not been initialized!"); Assert.True(emptyConfig.NullableBooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Nullable boolean field has not been initialized!"); Assert.True(emptyConfig.DoubleField.CompareTo(RuntimeConfigManagerTestConfig1.DoubleFieldDefault) == 0, "Double field has not been initialized!"); Assert.True(emptyConfig.IntField == RuntimeConfigManagerTestConfig1.IntFieldDefault, "Integer field has not been initialized!"); Assert.True(emptyConfig.StringField == RuntimeConfigManagerTestConfig1.StringFieldDefault, "String field has not been initialized!"); Assert.True(emptyConfig.ByteField == RuntimeConfigManagerTestConfig1.ByteFieldDefault, "Byte field has not been initialized!"); Assert.True(emptyConfig.LongField == RuntimeConfigManagerTestConfig1.LongFieldDefault, "Long field has not been initialized!"); }
public void DoNotOverrideSetFieldsTest() { // create a new config var emptyConfig = new RuntimeConfigManagerTestConfig1(); // set the value of the properties to non-system-default emptyConfig.ByteField = 129; emptyConfig.DoubleField = 0.1; emptyConfig.EnumField = TestConfig1Enum.EnumValue2; emptyConfig.IntField = 130; emptyConfig.LongField = 140; emptyConfig.NullableBooleanField = false; emptyConfig.StringField = ""; // it makes no sense to test boolean here! // check if all properties are now not the same like the configured default values. Assert.False(emptyConfig.NullableBooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Nullable Boolean: The system default value equals the test setup default value."); Assert.False(emptyConfig.BooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Boolean: The system default value equals the test setup default value."); Assert.False(emptyConfig.ByteField == RuntimeConfigManagerTestConfig1.ByteFieldDefault, "Byte: The system default value equals the test setup default value."); Assert.False(emptyConfig.DoubleField.CompareTo(RuntimeConfigManagerTestConfig1.DoubleFieldDefault) == 0, "Double: The system default value equals the test setup default value."); Assert.False(emptyConfig.EnumField == RuntimeConfigManagerTestConfig1.EnumFieldDefault, "Enum: The system default value equals the test setup default value."); Assert.False(emptyConfig.IntField == RuntimeConfigManagerTestConfig1.IntFieldDefault, "Integer: The system default value equals the test setup default value."); Assert.False(emptyConfig.LongField == RuntimeConfigManagerTestConfig1.LongFieldDefault, "Long: The system default value equals the test setup default value."); Assert.False(emptyConfig.StringField == RuntimeConfigManagerTestConfig1.StringFieldDefault, "String: The system default value equals the test setup default value."); // fillup empty properties _manager.FillEmpty(emptyConfig); // check that no property value has been overwritten. Assert.False(emptyConfig.EnumField == RuntimeConfigManagerTestConfig1.EnumFieldDefault, "Enum field has been overwritten!"); Assert.False(emptyConfig.NullableBooleanField == RuntimeConfigManagerTestConfig1.BooleanFieldDefault, "Nullable boolean field has not been overwritten!"); Assert.False(emptyConfig.DoubleField.CompareTo(RuntimeConfigManagerTestConfig1.DoubleFieldDefault) == 0, "Double field has not been overwritten!"); Assert.False(emptyConfig.IntField == RuntimeConfigManagerTestConfig1.IntFieldDefault, "Integer field has not been overwritten!"); Assert.False(emptyConfig.StringField == RuntimeConfigManagerTestConfig1.StringFieldDefault, "String field has not been overwritten!"); Assert.False(emptyConfig.ByteField == RuntimeConfigManagerTestConfig1.ByteFieldDefault, "Byte field has not been overwritten!"); Assert.False(emptyConfig.LongField == RuntimeConfigManagerTestConfig1.LongFieldDefault, "Long field has not been overwritten!"); }