Пример #1
0
        public void GetAll_WithExistingContributionFile_DoesNotThrow()
        {
            var contributionFile1Model = new ContributionFileModel
            {
                Id = 11,
                AssociatedContribution = new CommentLightModel(),
                FileFormat             = SupportedFormatFile.Zip
            };

            var contributionFile2Model = new ContributionFileModel
            {
                Id = 12,
                AssociatedContribution = new CommentLightModel(),
                FileFormat             = SupportedFormatFile.TarGz
            };

            var returnedContributionFile1 = RepositorySUT.Add(contributionFile1Model);
            var returnedContributionFile2 = RepositorySUT.Add(contributionFile2Model);
            var allContributionFiles      = RepositorySUT.GetAll();

            Assert.NotNull(returnedContributionFile1);
            Assert.NotNull(returnedContributionFile2);
            Assert.NotEmpty(allContributionFiles);

            RepositorySUT.Remove(returnedContributionFile1.Id);
            RepositorySUT.Remove(returnedContributionFile2.Id);
        }
Пример #2
0
        public void Create_NonExisting_DoesNotThrow()
        {
            var contributionFileModel = new ContributionFileModel
            {
                Id = 10,
                AssociatedContribution = new CommentLightModel(),
                FileFormat             = SupportedFormatFile.Zip
            };

            var returnedContributionFile = RepositorySUT.Add(contributionFileModel);

            Assert.NotNull(returnedContributionFile);
            RepositorySUT.Remove(returnedContributionFile.Id);
        }
Пример #3
0
        public void Remove_WithExistingContributionFile_DoesNotThrow()
        {
            var contributionFileModel = new ContributionFileModel
            {
                Id = 15,
                AssociatedContribution = new CommentLightModel(),
                FileFormat             = SupportedFormatFile.Zip
            };

            RepositorySUT.Add(contributionFileModel);
            RepositorySUT.Remove(contributionFileModel.Id);
            var returnedContributionFile = RepositorySUT.GetById(contributionFileModel.Id);

            Assert.Null(returnedContributionFile);
        }
Пример #4
0
        public ContributionFile MapContributionFileModelToContributionFile(ContributionFileModel model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new ContributionFile
            {
                Id = model.Id,
                FileName = model.FileName,
                Content = model.Content,
                AssociatedContribution = MapContributionLightModelToContribution(model.AssociatedContribution),
                FileFormat = model.FileFormat
            });
        }
Пример #5
0
        public void ChangeFormat_WithExistingContributionFile_DoesNotThrow()
        {
            var contributionFileModel = new ContributionFileModel
            {
                Id = 14,
                AssociatedContribution = new CommentLightModel(),
                FileFormat             = SupportedFormatFile.Zip
            };

            var addedContributionFile = RepositorySUT.Add(contributionFileModel);

            addedContributionFile.FileFormat = SupportedFormatFile.Rar;
            RepositorySUT.Update(addedContributionFile);

            var updatedContributionFile = RepositorySUT.GetById(addedContributionFile.Id);

            Assert.NotNull(updatedContributionFile);
            Assert.Equal(SupportedFormatFile.Rar, updatedContributionFile.FileFormat);

            RepositorySUT.Remove(updatedContributionFile.Id);
        }