public void TestAdd() { TestCtor (); // setup filter and sort desc SetupFilter (); SetupSortDesc (); // add songs and validate obj afterwards var song1 = new NotifySong ("Franz Schubert", "Abends unter der Linde"); model.Add (song1); var song2 = new NotifySong ("Kuuuuu", "onoonono"); model.Insert (1, song2); /* * when this test was written, the sample data was: * new NotifySong("Franz Schubert", "Die Kraehe"), new NotifySong("The Beatles", "Help"), new NotifySong("GGGG", "Abcd"), new NotifySong("Franz Schubert", "Meeres Stille") * * therfore according to the sort rules above, the data after the 2 insert * actions should now look like this: new NotifySong("GGGG", "Abcd"), new NotifySong ("Kuuuuu", "onoonono"), new NotifySong("The Beatles", "Help") * */ NotifySong [] songs = { new NotifySong("GGGG", "Abcd"), new NotifySong ("Kuuuuu", "onoonono"), new NotifySong("The Beatles", "Help") }; var i = 0; foreach (NotifySong item in obj) { // System.Console.WriteLine ("Original: " + songs [i]); // System.Console.WriteLine ("CollectionView: " + item); Assert.AreEqual (songs [i].Artist, item.Artist); Assert.AreEqual (songs [i].Title, item.Title); i++; } }
public void TestReplace() { TestCtor (); // setup filter and sort desc SetupFilter (); SetupSortDesc (); var song1 = new NotifySong ("OOOOO", "aaaaaaa"); model [2] = song1; model [3] = null; /* * when this test was written, the sample data was: * new NotifySong("Franz Schubert", "Die Kraehe"), new NotifySong("The Beatles", "Help"), new NotifySong("GGGG", "Abcd"), new NotifySong("Franz Schubert", "Meeres Stille") * * therfore according to the sort rules above, the data after the replace * actions should now look like this: null, new NotifySong("OOOOO", "aaaaaaa"), new NotifySong("The Beatles", "Help") * */ NotifySong [] songs = { null, new NotifySong("OOOOO", "aaaaaaa"), new NotifySong("The Beatles", "Help") }; var i = 0; foreach (NotifySong item in obj) { System.Console.WriteLine ("Original: " + songs [i]); System.Console.WriteLine ("CollectionView: " + item); if (songs [i] == null) { Assert.AreEqual (songs [i], item); } else { Assert.AreEqual (songs [i].Artist, item.Artist); Assert.AreEqual (songs [i].Title, item.Title); } i++; } }