public void Test_CreateClassDef_AddOnePropDef() { //---------------Set up test pack------------------- string assemblyName = "A" + RandomValueGenerator.GetRandomString(); string className = "C" + RandomValueGenerator.GetRandomString(); string propertyName = "P" + RandomValueGenerator.GetRandomString(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var classDefBuilder = new ClassDefBuilder(); ClassDef classDef = classDefBuilder.WithAssemblyName(assemblyName).WithClassName(className) .AddPropDef(new PropDefBuilder() .WithPropertyName(propertyName)); //---------------Test Result ----------------------- Assert.AreEqual(assemblyName, classDef.AssemblyName); Assert.AreEqual(className, classDef.ClassName); Assert.IsNotNull(classDef.PropDefcol); Assert.AreEqual(1, classDef.PropDefcol.Count()); Assert.IsNotNull(classDef.PropDefcol[propertyName]); Assert.IsNull(classDef.PrimaryKeyDef); Assert.IsNull(classDef.KeysCol); Assert.IsNull(classDef.RelationshipDefCol); Assert.AreEqual(0, classDef.UIDefCol.Count()); }
public void Test_Default_Construct_WithValue_ShouldSetValue() { //---------------Set up test pack------------------- string defaultValue = RandomValueGenerator.GetRandomString(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var attribute = new AutoMapDefaultAttribute(defaultValue); //---------------Test Result ----------------------- Assert.AreSame(defaultValue, attribute.DefaultValue); }
public void CreateAutoMapOneToManyAttribute_WhenHasReverseRelName_ShouldSetReverseRelNameAndDeleteActionPrevent() { //---------------Set up test pack------------------- var reverseRelationshipName = RandomValueGenerator.GetRandomString(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var attribute = new AutoMapOneToManyAttribute(reverseRelationshipName); //---------------Test Result ----------------------- Assert.AreEqual(reverseRelationshipName, attribute.ReverseRelationshipName); Assert.AreEqual(DeleteParentAction.Prevent, attribute.DeleteParentAction); }
public void Test_CreatePropDef_WithAutoIncrementingProp() { //---------------Set up test pack------------------- string propertyName = "P" + RandomValueGenerator.GetRandomString(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- PropDef propDef = new PropDefBuilder() .WithPropertyName(propertyName) .IsAutoIncrementing(); //---------------Test Result ----------------------- Assert.AreEqual(propertyName, propDef.PropertyName); Assert.IsTrue(propDef.AutoIncrementing); }
public void Test_CreatePropDef_WithReadWriteRule() { //---------------Set up test pack------------------- string propertyName = "P" + RandomValueGenerator.GetRandomString(); const PropReadWriteRule propReadWriteRule = PropReadWriteRule.WriteNew; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- PropDef propDef = new PropDefBuilder() .WithPropertyName(propertyName) .WithReadWriteRule(propReadWriteRule); //---------------Test Result ----------------------- Assert.AreEqual(propertyName, propDef.PropertyName); Assert.AreEqual(propReadWriteRule, propDef.ReadWriteRule); }
public void Test_CreatePropDef_WithTypeName() { //---------------Set up test pack------------------- string propertyName = "P" + RandomValueGenerator.GetRandomString(); string typeName = "T" + RandomValueGenerator.GetRandomString(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- PropDef propDef = new PropDefBuilder() .WithPropertyName(propertyName) .WithTypeName(typeName); //---------------Test Result ----------------------- Assert.AreEqual(propertyName, propDef.PropertyName); Assert.AreEqual(typeName, propDef.PropertyTypeName); }
public void Test_MapClassesForAssembly_ShouldAlwaysResetTheClassDefCol_ShouldMapAllClassesIntheAssembly() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; ClassDefCol classDefCol = thisAssembly.MapClasses(); var fakeExtBO = classDefCol.FirstOrDefault(def => def.ClassName == "FakeExtBoShouldBeLoaded"); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- fakeExtBO.TypeParameter = RandomValueGenerator.GetRandomString(); ClassDefCol classDefCol2 = thisAssembly.MapClasses(); //---------------Test Result ----------------------- var fakeExtBO2 = classDefCol2.FirstOrDefault(def => def.ClassName == "FakeExtBoShouldBeLoaded"); Assert.AreNotSame(fakeExtBO2, fakeExtBO); Assert.AreNotEqual(fakeExtBO2.TypeParameter, fakeExtBO.TypeParameter); }
public void Test_CreatePropDef_WithPropertyName() { //---------------Set up test pack------------------- string propertyName = "P" + RandomValueGenerator.GetRandomString(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- PropDef propDef = new PropDefBuilder() .WithPropertyName(propertyName); //---------------Test Result ----------------------- Assert.AreEqual(propertyName, propDef.PropertyName); Assert.AreEqual("System", propDef.PropertyTypeAssemblyName); Assert.AreEqual("String", propDef.PropertyTypeName); Assert.AreEqual(PropReadWriteRule.ReadWrite, propDef.ReadWriteRule); Assert.AreEqual(propertyName, propDef.DatabaseFieldName); Assert.IsNull(propDef.DefaultValueString); Assert.IsFalse(propDef.Compulsory); Assert.IsFalse(propDef.AutoIncrementing); Assert.IsFalse(propDef.KeepValuePrivate); }
public FakeMethodInfo() { _declaringType = MockRepository.GenerateMock <Type>(); _propType = MockRepository.GenerateMock <Type>(); _methodName = RandomValueGenerator.GetRandomString(); }
private string GetRandomMessage() { return(RandomValueGenerator.GetRandomString()); }
private static string GetRandomFieldName() { return(RandomValueGenerator.GetRandomString()); }