Ejemplo n.º 1
0
        public void Update_ArtistLinks()
        {
            // Arrange
            var circle      = repository.Save(CreateEntry.Circle());
            var illustrator = repository.Save(CreateEntry.Artist(ArtistType.Illustrator));

            var contract = new ArtistForEditContract(vocalist, ContentLanguagePreference.English)
            {
                Groups = new[] {
                    new ArtistForArtistContract {
                        Parent = new ArtistContract(circle, ContentLanguagePreference.English)
                    },
                },
                Illustrator = new ArtistContract(illustrator, ContentLanguagePreference.English)
            };

            // Act
            CallUpdate(contract);

            // Assert
            var artistFromRepo = repository.Load(contract.Id);

            Assert.AreEqual(2, artistFromRepo.AllGroups.Count, "Number of groups");
            Assert.IsTrue(artistFromRepo.HasGroup(circle), "Has group");
            Assert.IsTrue(artistFromRepo.HasGroup(illustrator), "Has illustrator");
            Assert.AreEqual(ArtistLinkType.Group, artistFromRepo.Groups.First(g => g.Parent.Equals(circle)).LinkType, "Artist link type for circle");
            Assert.AreEqual(ArtistLinkType.Illustrator, artistFromRepo.Groups.First(g => g.Parent.Equals(illustrator)).LinkType, "Artist link type for illustrator");
        }
Ejemplo n.º 2
0
        public async Task Update_ArtistLinks()
        {
            // Arrange
            var circle      = _repository.Save(CreateEntry.Circle());
            var illustrator = _repository.Save(CreateEntry.Artist(ArtistType.Illustrator));

            var contract = new ArtistForEditContract(_vocalist, ContentLanguagePreference.English, new InMemoryImagePersister())
            {
                Groups = new[] {
                    new ArtistForArtistContract {
                        Parent = new ArtistContract(circle, ContentLanguagePreference.English)
                    },
                },
                Illustrator = new ArtistContract(illustrator, ContentLanguagePreference.English)
            };

            // Act
            await CallUpdate(contract);

            // Assert
            var artistFromRepo = _repository.Load(contract.Id);

            artistFromRepo.AllGroups.Count.Should().Be(2, "Number of groups");
            artistFromRepo.HasGroup(circle).Should().BeTrue("Has group");
            artistFromRepo.HasGroup(illustrator).Should().BeTrue("Has illustrator");
            artistFromRepo.Groups.First(g => g.Parent.Equals(circle)).LinkType.Should().Be(ArtistLinkType.Group, "Artist link type for circle");
            artistFromRepo.Groups.First(g => g.Parent.Equals(illustrator)).LinkType.Should().Be(ArtistLinkType.Illustrator, "Artist link type for illustrator");
        }
Ejemplo n.º 3
0
        public void Update_ArtistLinks_IgnoreInvalid()
        {
            // Arrange
            var circle  = repository.Save(CreateEntry.Circle());
            var circle2 = repository.Save(CreateEntry.Circle());

            // Cannot add character designer for producer
            var contract = new ArtistForEditContract(artist, ContentLanguagePreference.English)
            {
                AssociatedArtists = new[] {
                    new ArtistForArtistContract(new ArtistForArtist(circle, artist, ArtistLinkType.CharacterDesigner), ContentLanguagePreference.English),
                },
                Groups = new[] {
                    new ArtistForArtistContract(new ArtistForArtist(circle2, artist, ArtistLinkType.Group), ContentLanguagePreference.English)
                }
            };

            // Act
            CallUpdate(contract);

            // Assert
            Assert.AreEqual(1, artist.AllGroups.Count, "Number of linked artists");
            Assert.IsFalse(artist.HasGroup(circle), "Character designer was not added");
        }
Ejemplo n.º 4
0
        public async Task Update_ArtistLinks_IgnoreInvalid()
        {
            // Arrange
            var circle  = _repository.Save(CreateEntry.Circle());
            var circle2 = _repository.Save(CreateEntry.Circle());

            // Cannot add character designer for producer
            var contract = new ArtistForEditContract(_artist, ContentLanguagePreference.English, new InMemoryImagePersister())
            {
                AssociatedArtists = new[] {
                    new ArtistForArtistContract(new ArtistForArtist(circle, _artist, ArtistLinkType.CharacterDesigner), ContentLanguagePreference.English),
                },
                Groups = new[] {
                    new ArtistForArtistContract(new ArtistForArtist(circle2, _artist, ArtistLinkType.Group), ContentLanguagePreference.English)
                }
            };

            // Act
            await CallUpdate(contract);

            // Assert
            _artist.AllGroups.Count.Should().Be(1, "Number of linked artists");
            _artist.HasGroup(circle).Should().BeFalse("Character designer was not added");
        }