public void Have_DataTypeAttribute() { // Arrange string propertyName = "CreatedOn"; PhotoViewModel photoViewModel = new PhotoViewModel(); // Act bool hasAttribute = photoViewModel.GetType() .GetProperty(propertyName) .GetCustomAttributes(false) .Where(p => p.GetType() == typeof(DataTypeAttribute)) .Any(); // Assert Assert.IsTrue(hasAttribute); }