public void ContactInformation_VerifyNumberOfProperties() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperties() .Count(); Assert.AreEqual(9, result); }
public void ContactInformationClass_ShouldImplement_IDbModelInterface() { var obj = new ContactInformation(); var result = obj.GetType() .GetInterfaces() .Any(x => x == typeof(IDbModel)); Assert.IsTrue(result); }
public void ContactInformation_VerifyNumberOfConstructors() { var obj = new ContactInformation(); var methodsCount = obj.GetType() .GetMethods() .Count(); var propertiesCount = obj.GetType() .GetProperties() .Count(); var result = obj.GetType() .GetMembers() .Count(); result = result - propertiesCount - methodsCount; Assert.AreEqual(1, result); }
public void Address_ShouldBe_Virtual() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperty("Address") .GetAccessors() .Any(x => x.IsVirtual); Assert.IsTrue(result); }
public void ContactInformation_VerifyNumberOfMethods() { var methodsFromFramework = 4; var expectedMethodsCount = 0; var totalMethodsCount = methodsFromFramework + expectedMethodsCount; var obj = new ContactInformation(); var numberOfMethodsComeFromProperties = obj.GetType() .GetProperties() .Select(x => 2) .Sum(); var result = obj.GetType() .GetMethods() .Count(); result = result - numberOfMethodsComeFromProperties; Assert.AreEqual(totalMethodsCount, result); }
public void Email_ShouldHave_RegularExpressionhAttribute() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperty("Email") .GetCustomAttributes(false) .Where(x => x.GetType() == typeof(RegularExpressionAttribute)) .Any(); Assert.IsTrue(result); }
public void PhoneNumber_ShouldHave_MaxLengthAttribute() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperty("PhoneNumber") .GetCustomAttributes(false) .Where(x => x.GetType() == typeof(MaxLengthAttribute)) .Any(); Assert.IsTrue(result); }
public void Id_ShouldHave_KeyAttribute() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperty("Id") .GetCustomAttributes(false) .Where(x => x.GetType() == typeof(KeyAttribute)) .Any(); Assert.IsTrue(result); }
public void Email_ShouldHave_RightValueFor_RegularExpressionAttribute() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperty("Email") .GetCustomAttributes(false) .Where(x => x.GetType() == typeof(RegularExpressionAttribute)) .Select(x => (RegularExpressionAttribute)x) .SingleOrDefault(); Assert.IsNotNull(result); Assert.AreEqual(RegexConstants.Email, result.Pattern); }
public void Email_ShouldHave_RightValueFor_MaxLengthAttribute() { var obj = new ContactInformation(); var result = obj.GetType() .GetProperty("Email") .GetCustomAttributes(false) .Where(x => x.GetType() == typeof(MaxLengthAttribute)) .Select(x => (MaxLengthAttribute)x) .SingleOrDefault(); Assert.IsNotNull(result); Assert.AreEqual(ValidationConstants.EmailMaxLength, result.Length); }