private GenerateValidValue ( int overridingMinValue, int overridingMaxValue ) : int | ||
overridingMinValue | int | |
overridingMaxValue | int | |
리턴 | int |
public void Test_GenerateValue_WhenInt_ShouldRetInt() { IPropDef def = new PropDefFake { PropertyType = typeof(int) }; ValidValueGenerator valueGenerator = new ValidValueGeneratorIncrementalInt(def); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- object value = valueGenerator.GenerateValidValue(); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.IsInstanceOf(typeof(int), value); Assert.AreNotEqual(valueGenerator.GenerateValidValue(), value); }
public void Test_GenerateValue_WhenSecondTime_WhenConstructedAgain_WhenNoRule_ShouldRetOne() { IPropDef def = new PropDefFake { PropertyType = typeof(int) }; ValidValueGenerator valueGenerator = new ValidValueGeneratorIncrementalInt(def); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- object firstValue = valueGenerator.GenerateValidValue(); object secondValue = new ValidValueGeneratorIncrementalInt(def).GenerateValidValue(); //---------------Test Result ----------------------- Assert.IsNotNull(secondValue); Assert.IsInstanceOf(typeof(int), secondValue); Assert.AreEqual(1, secondValue); Assert.AreNotEqual(firstValue, secondValue); }
public void Test_GenerateValue_WhenIntAndRule_AndNextValGTMaxVal_ShouldRestartAtMin() { //---------------Set up test pack------------------- IPropDef def = new PropDefFake { PropertyType = typeof(int) }; const int minValue = 3; const int maxValue = 4; def.AddPropRule(CreatePropRuleInt(minValue, maxValue)); ValidValueGenerator generator = new ValidValueGeneratorIncrementalInt(def); //---------------Assert Precondition---------------- Assert.AreSame(typeof(int), def.PropertyType); Assert.IsNotEmpty(def.PropRules.OfType<PropRuleInteger>().ToList()); PropRuleInteger propRule = def.PropRules.OfType<PropRuleInteger>().First(); Assert.AreEqual(minValue, propRule.MinValue); Assert.AreEqual(maxValue, propRule.MaxValue); //---------------Execute Test ---------------------- var value1 = (int)generator.GenerateValidValue(); var value2 = (int)generator.GenerateValidValue(); int value3 = (int)generator.GenerateValidValue(); //---------------Test Result ----------------------- Assert.AreEqual(minValue, value1); Assert.AreEqual(maxValue, value2); Assert.AreEqual(minValue, value3); }