public void IsDatasetNominationValidForUpdate_OtherLicenseContentTooLong(NominationLicenseType licenseType, bool expectError)
        {
            var nomination = new DatasetNomination
            {
                NominationLicenseType   = licenseType,
                OtherLicenseContentHtml = new string('*', Constraints.OtherLicenseContentHtml + 1)
            };

            IsMessageFoundForUpdate($"License Content must be maximum of {Constraints.OtherLicenseContentHtml} characters.", nomination).Should().Be(expectError);
        }
        public void IsDatasetNominationValidForUpdate_MissingOtherLicenseName(NominationLicenseType licenseType, bool expectError)
        {
            var nomination = new DatasetNomination
            {
                NominationLicenseType = licenseType,
                OtherLicenseName      = String.Empty
            };

            IsMessageFoundForUpdate("License Name is required.", nomination).Should().Be(expectError);
        }
        public void IsDatasetNominationValidForUpdate_OtherLicenseContentRequired(NominationLicenseType licenseType, bool expectError)
        {
            var nomination = new DatasetNomination
            {
                NominationLicenseType   = licenseType,
                OtherLicenseContentHtml = string.Empty
            };

            IsMessageFoundForUpdate("License Content is required.", nomination).Should().Be(expectError);
        }
        public void IsDatasetNominationValidForUpdate_OtherLicenseFileNameTooLong(NominationLicenseType licenseType, bool expectError)
        {
            var nomination = new DatasetNomination
            {
                NominationLicenseType = licenseType,
                OtherLicenseFileName  = new string('*', Constraints.MaxFileNameLength + 1)
            };

            IsMessageFoundForUpdate($"License File Name must be maximum of {Constraints.MaxFileNameLength} characters.", nomination).Should().Be(expectError);
        }
        private DatasetNomination CreateNominationForLicensePropertyTests(NominationLicenseType licenseType)
        {
            var licenseId      = Guid.NewGuid();
            var isOtherLicense = licenseType == NominationLicenseType.HtmlText ||
                                 licenseType == NominationLicenseType.InputFile;

            var nomination = new DatasetNomination()
            {
                NominationLicenseType         = licenseType,
                LicenseId                     = isOtherLicense ? default(Guid) : licenseId,
                OtherLicenseContentHtml       = licenseType == NominationLicenseType.HtmlText ? "OtherLicenseContentHtml" : null,
                OtherLicenseFileName          = licenseType == NominationLicenseType.InputFile ? "OtherLicenseFileName" : null,
                OtherLicenseAdditionalInfoUrl = "OtherLicenseAdditionalInfoUrl",
                OtherLicenseName              = "OtherLicenseName"
            };

            return(nomination);
        }
        private DatasetNominationStorageItem CreateNominationStorageItemForLicensePropertyTests(NominationLicenseType licenseType)
        {
            var licenseId      = new Guid();
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("OtherLicenseContentHtml");
            var contentHtml    = Convert.ToBase64String(plainTextBytes);

            var storageItem = new DatasetNominationStorageItem()
            {
                NominationLicenseType         = licenseType,
                LicenseId                     = licenseId,
                OtherLicenseContentHtml       = contentHtml,
                OtherLicenseFileName          = "OtherLicenseFileName",
                OtherLicenseAdditionalInfoUrl = "OtherLicenseAdditionalInfoUrl",
                OtherLicenseName              = "OtherLicenseName"
            };

            return(storageItem);
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            NominationLicenseType licenseType = (NominationLicenseType?)value ?? DefaultType;

            writer.WriteValue(licenseType.ToString());
        }