Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
            }
        }