public void Initialize()
        {
            ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(new StandardKernel()));

            var attachment = new Attachment
            {
                FileName = "network.jpg",
                FileDiskName = "network.jpg",
                FilePath = "images",
                FileType = "image/jpeg"
            };

            var service = MockRepository.GenerateMock<IAttachmentService>();

            service.Stub(x => x.GetById(1)).Return(attachment);

            service.Stub(x => x.GetById(2)).Return(new Attachment
            {
                FileName = "fake.jpg",
                FileDiskName = "fake.jpg",
                FilePath = "fake",
                FileType = "fake"
            });

            service.Stub(x => x.GetThumbnail(attachment, 100, 100)).Return(new FileInfo(attachment.FullPath.AsPath()));

            var controller = new AttachmentController(service);

            this.AttachmentController = controller;
        }
Exemple #2
0
        public void Test_Attachment_FullPath()
        {
            var attachment = new Attachment
            {
                FilePath = "directory",
                FileDiskName = "test.zip"
            };

            Assert.AreEqual("directory/test.zip", attachment.FullPath);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AttachmentDelete"/> class.
        /// </summary>
        /// <param name="attachment">The attachment.</param>
        public AttachmentDelete(Attachment attachment)
        {
            if (attachment == null)
            {
                throw new ArgumentNullException("attachment");
            }

            this.Id = attachment.Id;
            this.Title = attachment.FileName;
            this.Soft = true;
        }
        public void Test_AttachmentUpdate_ValueToModel()
        {
            var value = new AttachmentUpdate
            {
                FileName = "test"
            };

            var attachment = new Attachment();

            value.ValueToModel(attachment);

            Assert.AreEqual("test", value.FileName, "FileName");
        }
        public void Test_AttachmentService_GetThumbnail()
        {
            var attachment = new Attachment
            {
                FileDiskName = "test.jpg",
                FilePath = "\\images",
                FileWidth = 200,
                FileHeight = 200
            };

            var result = this.AttachmentService.GetThumbnail(attachment, 100, 100);

            Assert.IsNotNull(result, "Result");
            Assert.AreEqual("C:\\images\\test_100_100.jpg", result.FullName, "FileName");
        }
 public void Insert(Attachment entity)
 {
 }
 public FileInfo GetThumbnail(Attachment attachment, int width, int height)
 {
     return null;
 }
 public void Delete(Attachment attachment, bool soft)
 {
 }
 public void Delete(Attachment entity)
 {
 }
 public void Update(Attachment entity)
 {
 }