public void Delete_Person_Will_Not_Throw_Exception()
        {
            testStory.Book = testBook;
            testStory.AddAuthor(testPerson);

            Session.Save(testPerson);
            Session.Save(testStory);
            Session.Save(testBook);
            Session.Flush();
            Session.Refresh(testPerson);

            Assert.DoesNotThrow(() => TransactionWrappedDelete(testPerson));
        }
Exemple #2
0
        public void Can_Discern_Different_BookTypes()
        {
            var asimov = new Person {
                Surname = "Asimov"
            };
            var clarke = new Person {
                Surname = "Clarke"
            };

            Story asimovStory1 = new Story(), asimovStory2 = new Story(), clarkeStory = new Story();

            asimovStory1.AddAuthor(asimov);
            asimovStory2.AddAuthor(asimov);
            clarkeStory.AddAuthor(clarke);

            var novel = new Book {
                Title = "How Novel!"
            };

            var collection = new Book();

            collection.AddStory(asimovStory1);
            collection.AddStory(asimovStory2);

            var anthology = new Book();

            anthology.AddStory(asimovStory1);
            anthology.AddStory(clarkeStory);

            Assert.That(novel.BookType, Is.EqualTo(BookType.Novel));
            Assert.That(collection.BookType, Is.EqualTo(BookType.Collection));
            Assert.That(anthology.BookType, Is.EqualTo(BookType.Anthology));
        }
Exemple #3
0
        public void Has_Tags_From_All_Related_Stories()
        {
            Tag cool = new Tag(), hot = new Tag(), old = new Tag(), sweet = new Tag();

            Story story1 = new Story(), story2 = new Story(), story3 = new Story();

            story1.AddTag(cool);
            story1.AddTag(hot);
            story2.AddTag(cool);
            story2.AddTag(old);
            story3.AddTag(sweet);

            var someBook = new Book();

            someBook.AddStory(story3);

            var tolkien = new Person();

            story1.AddAuthor(tolkien);
            story2.AddTranslator(tolkien);
            someBook.AddEditor(tolkien);

            Assert.That(tolkien.Tags.Contains(cool));
            Assert.That(tolkien.Tags.Contains(hot));
            Assert.That(tolkien.Tags.Contains(old));
            Assert.That(tolkien.Tags.Contains(sweet));
            Assert.That(tolkien.Tags.Count(), Is.EqualTo(4));
        }
Exemple #4
0
        public void Contains_CoAuthors_From_Stories()
        {
            var myBook = new Book();

            var story1 = new Story();

            var tolkien      = new Person();
            var sonOfTolkien = new Person();

            story1.AddAuthor(tolkien);
            story1.AddAuthor(sonOfTolkien);
            myBook.AddStory(story1);

            Assert.That(myBook.AllAuthors.Count(), Is.EqualTo(2));
            Assert.That(myBook.AllAuthors.ToList(), Has.Member(tolkien));
            Assert.That(myBook.AllAuthors.ToList(), Has.Member(sonOfTolkien));
        }
Exemple #5
0
        public void Remove_Author_Will_Remove_From_Story_Authors_Property()
        {
            var story = new Story();

            story.AddAuthor(new Person());
            story.RemoveAuthor(story.Authors.Single());
            Assert.That(story.Authors.Count(), Is.EqualTo(0));
        }
Exemple #6
0
        public void ClearAuthors_Will_Make_Authors_Property_Empty()
        {
            var story = new Story();

            story.AddAuthor(new Person());
            story.ClearAuthors();
            Assert.That(story.Authors.Count(), Is.EqualTo(0));
        }
Exemple #7
0
        public void Can_Derive_Author_Role_From_AuthoredStories()
        {
            var person = new Person();
            var story  = new Story();

            story.AddAuthor(person);
            Assert.That(person.Roles.Contains(Role.Author));
        }
Exemple #8
0
        public void Can_Add_Author()
        {
            var story  = new Story();
            var person = new Person();

            story.AddAuthor(person);
            Assert.That(story.Authors.Count(), Is.EqualTo(1));
            Assert.That(person.AuthoredStories.Count(), Is.EqualTo(1));
        }
Exemple #9
0
        public void ClearAuthors_Will_Remove_Story_From_Person_AuthoredStories()
        {
            var story  = new Story();
            var person = new Person();

            story.AddAuthor(person);
            story.ClearAuthors();
            Assert.That(person.AuthoredStories.Count(), Is.EqualTo(0));
        }
Exemple #10
0
        public void Remove_Author_Will_Remove_From_Person_AuthoredStorys_Property()
        {
            var story  = new Story();
            var person = new Person();

            story.AddAuthor(person);
            story.RemoveAuthor(person);
            Assert.That(person.AuthoredStories.Count(), Is.EqualTo(0));
        }
Exemple #11
0
        public void Will_Have_Same_Number_Of_AuthoredStories_As_Source_Entity()
        {
            var person = new Person();
            var story  = new Story();

            story.AddAuthor(person);
            var model = mapper.ModelFromEntity(person);

            Assert.That(model.AuthoredStories.Count(), Is.EqualTo(1));
        }
Exemple #12
0
        public void Can_Map_Authors()
        {
            var story  = new Story();
            var person = new Person();

            story.AddAuthor(person);
            var result = mapper.ModelFromEntity(story);

            Assert.That(result.Authors.Count(), Is.EqualTo(1));
        }
        public void Save_Will_Cascade_To_StoryAuthors()
        {
            var person = new Person {
                Surname = "Asimov"
            };
            var story = new Story();

            story.AddAuthor(person);
            Session.Save(person);
            Session.Save(story);
            Session.Flush();
            Session.Refresh(story);
            Assert.That(story.Authors, Is.Not.Empty);
        }
Exemple #14
0
        public void Has_Single_Author_For_Novel()
        {
            var novel = new Book();

            var story = new Story();

            novel.AddStory(story);

            var person = new Person();

            story.AddAuthor(person);

            Assert.That(novel.AllAuthors.Count(), Is.EqualTo(1));
            Assert.That(novel.AllAuthors.First(), Is.EqualTo(person));
        }