本文整理汇总了C#中Genre.AddArtists方法的典型用法代码示例。如果您正苦于以下问题:C# Genre.AddArtists方法的具体用法?C# Genre.AddArtists怎么用?C# Genre.AddArtists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Genre
的用法示例。
在下文中一共展示了Genre.AddArtists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateGenreWithArtists
public void ShouldCreateGenreWithArtists()
{
Genre savedGenre = new Genre { Name = "Pop" };
List<Artist> artists = new List<Artist> {
new Artist { Name = "1" },
new Artist { Name = "2" }
};
savedGenre.AddArtists(artists);
Session.SaveOrUpdate(savedGenre);
m_uow.Commit();
Session.Clear();
Genre retrievedGenre = Session.Get<Genre>(1);
Assert.AreNotEqual(null, retrievedGenre);
Assert.IsFalse(ReferenceEquals(savedGenre, retrievedGenre));
Assert.AreEqual(savedGenre.Name, retrievedGenre.Name);
Assert.AreEqual(savedGenre.Artists.Count, retrievedGenre.Artists.Count);
Assert.IsFalse(ReferenceEquals(savedGenre.Artists[0], retrievedGenre.Artists[0]));
Assert.AreEqual(savedGenre.Artists[0].Name, retrievedGenre.Artists[0].Name);
Assert.IsFalse(ReferenceEquals(savedGenre.Artists[1], retrievedGenre.Artists[1]));
Assert.AreEqual(savedGenre.Artists[1].Name, retrievedGenre.Artists[1].Name);
//new PersistenceSpecification<Genre>(Session)
// .CheckProperty(g => g.Id, 1) //identity starts at 1 - can't reset to zero
// .CheckProperty(g => g.Name, "Genre")
// .CheckList(g => g.Artists, artists, (g, a) => g.AddArtist(a))
// .VerifyTheMappings();
}
示例2: SetupContext
protected override void SetupContext(ISession session)
{
Mock<IValidator> v = new Mock<IValidator>();
m_repository = new ArtistsRepository(session, v.Object);
SortedDictionary<int, Artist> artists = new SortedDictionary<int, Artist>();
for (int i = 1; i <= 4; i++)
{
artists.Add(i, new Artist { Name = i.ToString() });
}
Genre pop = new Genre { Name = "Pop" };
pop.AddArtists(artists.Values.Take(2));
Genre rock = new Genre { Name = "Rock" };
rock.AddArtists(artists.Values.Skip(2).Take(2));
session.Save(pop);
session.Save(rock);
}