public void EntryUpdateWithPersonSaveAndLoadTest()
        {
            MakeTestCollections(false);

            // make an entry with an attached person
            AtomSite.Domain.AtomEntry entry = TestDataHelper.MakeTestEntry(TestCollection1Name);

            IAtomEntryRepository repository = GetEntryRepository();
            repository.CreateEntry(entry);

            IAtomEntryRepository repository2 = GetEntryRepository();
            AtomSite.Domain.AtomEntry updatedEntry = repository2.GetEntry(entry.Id);

            AtomSite.Domain.AtomPerson newPerson = new AtomSite.Domain.AtomPerson
            {
                Email = "fred@fred" + Guid.NewGuid() + ".com",
                Name = "TestPerson" + Guid.NewGuid()
            };

            updatedEntry.Authors = new List<AtomSite.Domain.AtomPerson> { newPerson };

            // update the entry
            repository2.UpdateEntry(updatedEntry);

            // load it again and check that the person is still there
            IAtomEntryRepository repository3 = GetEntryRepository();
            AtomSite.Domain.AtomEntry loadedEntry = repository3.GetEntry(entry.Id);

            Assert.AreEqual(1, loadedEntry.Authors.Count());

            AtomSite.Domain.AtomPerson loadedPerson = loadedEntry.Authors.First();

            DataTester.AssertPersonsEqual(newPerson, loadedPerson);        
        }
        public void EntryUpdateRemovePersonTest()
        {
            MakeTestCollections(false);

            // make an entry with two attached persons
            AtomSite.Domain.AtomEntry entry = TestDataHelper.MakeTestEntry(TestCollection1Name);

            AtomSite.Domain.AtomPerson newPerson1 = new AtomSite.Domain.AtomPerson
            {
                Email = "fred@fred" + Guid.NewGuid() + ".com",
                Name = "TestPerson" + Guid.NewGuid()
            };

            AtomSite.Domain.AtomPerson newPerson2 = new AtomSite.Domain.AtomPerson
            {
                Email = "bob@bob" + Guid.NewGuid() + ".com",
                Name = "TestPerson" + Guid.NewGuid()
            };

            entry.Authors = new List<AtomSite.Domain.AtomPerson> { newPerson1, newPerson2 };

            // save the entry
            IAtomEntryRepository repository = GetEntryRepository();
            repository.CreateEntry(entry);

            // load it again
            IAtomEntryRepository repository2 = GetEntryRepository();
            AtomSite.Domain.AtomEntry loadedEntry = repository2.GetEntry(entry.Id);

            Assert.AreEqual(2, loadedEntry.Authors.Count());

            // remove a person
            List<AtomSite.Domain.AtomPerson> persons = new List<AtomSite.Domain.AtomPerson>(loadedEntry.Authors);
            persons.RemoveAt(persons.Count - 1);

            loadedEntry.Authors = persons;

            repository2.UpdateEntry(loadedEntry);

            // load it again and check that a person has been removed
            IAtomEntryRepository repository3 = GetEntryRepository();
            AtomSite.Domain.AtomEntry reloadedEntry = repository3.GetEntry(entry.Id);

            Assert.AreEqual(1, reloadedEntry.Authors.Count());
        }