File size: 5,167 Bytes
fab29d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | using VersOne.Epub.Schema;
namespace VersOne.Epub.Test.Unit.Schema.Opf.Metadata
{
public class EpubMetadataContributorTests
{
private const string CONTRIBUTOR = "John Editor";
private const string ID = "contributor";
private const string FILE_AS = "Editor, John";
private const string ROLE = "editor";
private const EpubTextDirection TEXT_DIRECTION = EpubTextDirection.LEFT_TO_RIGHT;
private const string LANGUAGE = "en";
[Fact(DisplayName = "Constructing a EpubMetadataContributor instance with non-null parameters should succeed")]
public void ConstructorWithNonNullParametersTest()
{
EpubMetadataContributor epubMetadataContributor = new(CONTRIBUTOR, ID, FILE_AS, ROLE, TEXT_DIRECTION, LANGUAGE);
Assert.Equal(CONTRIBUTOR, epubMetadataContributor.Contributor);
Assert.Equal(ID, epubMetadataContributor.Id);
Assert.Equal(FILE_AS, epubMetadataContributor.FileAs);
Assert.Equal(ROLE, epubMetadataContributor.Role);
Assert.Equal(TEXT_DIRECTION, epubMetadataContributor.TextDirection);
Assert.Equal(LANGUAGE, epubMetadataContributor.Language);
}
[Fact(DisplayName = "Constructor should throw ArgumentNullException if contributor parameter is null")]
public void ConstructorWithNullContributorTest()
{
Assert.Throws<ArgumentNullException>(() => new EpubMetadataContributor(null!, ID, FILE_AS, ROLE, TEXT_DIRECTION, LANGUAGE));
}
[Fact(DisplayName = "Constructing a EpubMetadataContributor instance with null id parameter should succeed")]
public void ConstructorWithNullIdTest()
{
EpubMetadataContributor epubMetadataContributor = new(CONTRIBUTOR, null, FILE_AS, ROLE, TEXT_DIRECTION, LANGUAGE);
Assert.Equal(CONTRIBUTOR, epubMetadataContributor.Contributor);
Assert.Null(epubMetadataContributor.Id);
Assert.Equal(FILE_AS, epubMetadataContributor.FileAs);
Assert.Equal(ROLE, epubMetadataContributor.Role);
Assert.Equal(TEXT_DIRECTION, epubMetadataContributor.TextDirection);
Assert.Equal(LANGUAGE, epubMetadataContributor.Language);
}
[Fact(DisplayName = "Constructing a EpubMetadataContributor instance with null fileAs parameter should succeed")]
public void ConstructorWithNullFileAsTest()
{
EpubMetadataContributor epubMetadataContributor = new(CONTRIBUTOR, ID, null, ROLE, TEXT_DIRECTION, LANGUAGE);
Assert.Equal(CONTRIBUTOR, epubMetadataContributor.Contributor);
Assert.Equal(ID, epubMetadataContributor.Id);
Assert.Null(epubMetadataContributor.FileAs);
Assert.Equal(ROLE, epubMetadataContributor.Role);
Assert.Equal(TEXT_DIRECTION, epubMetadataContributor.TextDirection);
Assert.Equal(LANGUAGE, epubMetadataContributor.Language);
}
[Fact(DisplayName = "Constructing a EpubMetadataContributor instance with null role parameter should succeed")]
public void ConstructorWithNullRoleTest()
{
EpubMetadataContributor epubMetadataContributor = new(CONTRIBUTOR, ID, FILE_AS, null, TEXT_DIRECTION, LANGUAGE);
Assert.Equal(CONTRIBUTOR, epubMetadataContributor.Contributor);
Assert.Equal(ID, epubMetadataContributor.Id);
Assert.Equal(FILE_AS, epubMetadataContributor.FileAs);
Assert.Null(epubMetadataContributor.Role);
Assert.Equal(TEXT_DIRECTION, epubMetadataContributor.TextDirection);
Assert.Equal(LANGUAGE, epubMetadataContributor.Language);
}
[Fact(DisplayName = "Constructing a EpubMetadataContributor instance with null textDirection parameter should succeed")]
public void ConstructorWithNullTextDirectionTest()
{
EpubMetadataContributor epubMetadataContributor = new(CONTRIBUTOR, ID, FILE_AS, ROLE, null, LANGUAGE);
Assert.Equal(CONTRIBUTOR, epubMetadataContributor.Contributor);
Assert.Equal(ID, epubMetadataContributor.Id);
Assert.Equal(FILE_AS, epubMetadataContributor.FileAs);
Assert.Equal(ROLE, epubMetadataContributor.Role);
Assert.Null(epubMetadataContributor.TextDirection);
Assert.Equal(LANGUAGE, epubMetadataContributor.Language);
}
[Fact(DisplayName = "Constructing a EpubMetadataContributor instance with null language parameter should succeed")]
public void ConstructorWithNullLanguageTest()
{
EpubMetadataContributor epubMetadataContributor = new(CONTRIBUTOR, ID, FILE_AS, ROLE, TEXT_DIRECTION, null);
Assert.Equal(CONTRIBUTOR, epubMetadataContributor.Contributor);
Assert.Equal(ID, epubMetadataContributor.Id);
Assert.Equal(FILE_AS, epubMetadataContributor.FileAs);
Assert.Equal(ROLE, epubMetadataContributor.Role);
Assert.Equal(TEXT_DIRECTION, epubMetadataContributor.TextDirection);
Assert.Null(epubMetadataContributor.Language);
}
}
}
|