Beispiel #1
0
        public void AddAttachment_AttachmentIdNotSupplied_ArgumentExceptionThrow()
        {
            var attachmentId = Guid.Empty;
            var fileName     = "attachment.pdf";
            var contentType  = "image";

            byte[] content = new byte[] { 1, 2, 3, 4, 5 };

            _attachmentService = AttachmentServiceFactory.Create(MockRepository.GenerateStub <IJobAttachmentDataRepository>());
            AddAttachment(attachmentId, fileName, contentType, content);
        }
Beispiel #2
0
        public void AddAttachment_ContentTypeNotSupplied_ArgumentExceptionThrow()
        {
            var attachmentId = Guid.NewGuid();
            var fileName     = "attachment.pdf";
            var contentType  = String.Empty;
            var content      = new byte[] { 1, 2, 3, 4, 5 };

            _attachmentService = AttachmentServiceFactory.Create(MockRepository.GenerateStub <IJobAttachmentDataRepository>());
            AddAttachment(attachmentId, fileName, contentType, content);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Jobs.Messages.ContentTypeNotSupplied));
        }
Beispiel #3
0
        public void AddAttachment_FilenameGreaterThan2000Characters_ArgumentExceptionThrow()
        {
            var attachmentId = Guid.NewGuid();
            var fileName     = new string('a', 2001);
            var contentType  = "image";
            var content      = new byte[] { 1, 2, 3, 4, 5 };

            _attachmentService = AttachmentServiceFactory.Create(MockRepository.GenerateStub <IJobAttachmentDataRepository>());
            AddAttachment(attachmentId, fileName, contentType, content);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Jobs.Messages.FileNameTooLarge));
        }
Beispiel #4
0
        public void AddAttachment_UserDoesNotHaveMemberRole_ArgumentExceptionThrow()
        {
            var attachmentId = Guid.NewGuid();
            var fileName     = "attachment.pdf";
            var contentType  = "image";

            byte[] content = new byte[] { 1, 2, 3, 4, 5 };

            _attachmentService = AttachmentServiceFactory.Create(MockRepository.GenerateStub <IJobAttachmentDataRepository>(),
                                                                 TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public));
            AddAttachment(attachmentId, fileName, contentType, content);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Jobs.Messages.InsufficientSecurityClearance));
        }
Beispiel #5
0
        public void AddAttachment_ValidAttachmentDetails_AttachmentAdded()
        {
            var attachmentId = Guid.NewGuid();
            var fileName     = "attachment.pdf";
            var contentType  = "image";
            var content      = new byte[] { 1, 2, 3, 4, 5 };

            var attachmentDataRepositoryMock = MockRepository.GenerateMock <IJobAttachmentDataRepository>();

            attachmentDataRepositoryMock.Expect(x => x.Put(null)).IgnoreArguments();
            _attachmentService = AttachmentServiceFactory.Create(attachmentDataRepositoryMock);
            AddAttachment(attachmentId, fileName, contentType, content);
            attachmentDataRepositoryMock.VerifyAllExpectations();
        }
 public AttachmentsController(JobAttachmentService attachmentService)
 {
     _jobAttachmentService = attachmentService;
 }