public void PhotoPath_ShouldHave_RequiredAttribute() { TrollPhoto photo = new TrollPhoto(); string property = "PhotoPath"; bool hasAttribute = photo.GetType() .GetProperty(property) .GetCustomAttributes(false) .Where(p => p.GetType() == typeof(RequiredAttribute)) .Any(); Assert.IsTrue(hasAttribute); }
public void UploadTrollPhoto(string userId, string filePath) { Guard.WhenArgument(userId, "userId").IsNull().Throw(); Guard.WhenArgument(filePath, "filePath").IsNull().Throw(); TrollPhoto trollPhoto = new TrollPhoto() { UserId = userId, PhotoPath = filePath }; using (this.unitOfWork) { this.trollPhotoRepository.Add(trollPhoto); this.unitOfWork.Commit(); } }