예제 #1
0
        public void Should_list_all_books()
        {
            Catalogue catalogue = new Catalogue();
            catalogue.Add(new Book("1857239407", "George Lucas", "Star Wars: A New Hope", 256, 20));
            catalogue.Add(new Ebook("0450011844", "Frank Herbert", "Dune", 608));

            Assert.That(catalogue.GetTitles(), Is.EqualTo(new[]
            {
                "Dune",
                "Star Wars: A New Hope"
            }));
        }
        public void AddUnknownLibitemTest()
        {
            Catalogue      catalogue = new Catalogue();
            UnknownLibitem unknown   = new UnknownLibitem("unknown", 1999);

            Assert.Throws <System.ArgumentException>(() => catalogue.Add(unknown));
        }
        public void AddNullLibitemTest()
        {
            Catalogue catalogue = new Catalogue();
            Book      book      = null;

            Assert.Throws <System.ArgumentException>(() => catalogue.Add(book));
        }
        public void AddArticleTest()
        {
            Catalogue catalogue = new Catalogue();
            Article   article   = new Article("Einstein vs Weinstein", "Znany Profesor", 2019, 35);

            catalogue.Add(article);
            Assert.IsTrue(catalogue.Articles.Contains(article));
        }
        public void AddMovieTest()
        {
            Catalogue catalogue = new Catalogue();
            Movie     movie     = new Movie("Dwunastu gniewnych ludzi", "Sidney Lumet", 1957, 96);

            catalogue.Add(movie);
            Assert.IsTrue(catalogue.Movies.Contains(movie));
        }
        public void AddJournalTest()
        {
            Catalogue catalogue = new Catalogue();
            Journal   journal   = new Journal("Wnętrza Inspiracje", "Czasopisma krajowe", 2019, 3, 40, "Kuchnia w salonie");

            catalogue.Add(journal);
            Assert.IsTrue(catalogue.Journals.Contains(journal));
        }
        public void AddNewPaperTest()
        {
            Catalogue catalogue = new Catalogue();
            NewsPaper newsPaper = new NewsPaper("Gazeta Wyborcza", "Agora", 2019, 41, 28, "Dokąd idziemy?");

            catalogue.Add(newsPaper);
            Assert.IsTrue(catalogue.NewsPapers.Contains(newsPaper));
        }
        public void AddBookTest()
        {
            Catalogue catalogue = new Catalogue();
            Book      book      = new Book("Tajemna Historia", "Donna Tartt", 2015, 608, 1);

            catalogue.Add(book);
            Assert.IsTrue(catalogue.Books.Contains(book));
        }
        public void FindBookByAuthorAndTitleTest()
        {
            Catalogue catalogue = new Catalogue();
            Book      book      = new Book("Tajemna Historia", "Donna Tartt", 2015, 608, 1);

            catalogue.Add(book);

            Book findBook = catalogue.FindBookByAuthorAndTitle("Donna Tartt", "Tajemna Historia");

            Assert.AreSame(book, findBook);
        }
        public void FindArticleByAuthorAndTitleTest()
        {
            Catalogue catalogue = new Catalogue();
            Article   article   = new Article("Einstein vs Weinstein", "Znany Profesor", 2019, 35);

            catalogue.Add(article);

            Article findArticle = catalogue.FindArticleByAuthorAndTitle("Znany Profesor", "Einstein vs Weinstein");

            Assert.AreSame(article, findArticle);
        }
        public void FindNewsPaperByTitleAndNoTest()
        {
            Catalogue catalogue = new Catalogue();
            NewsPaper newsPaper = new NewsPaper("Gazeta Wyborcza", "Agora", 2019, 41, 28, "Dokąd idziemy?");

            catalogue.Add(newsPaper);

            NewsPaper findNewsPaper = catalogue.FindNewsPaperByTitleAndNo("Gazeta Wyborcza", 41);

            Assert.AreSame(newsPaper, findNewsPaper);
        }
        public void FindMovieByDirectorAndTitleTest()
        {
            Catalogue catalogue = new Catalogue();
            Movie     movie     = new Movie("Dwunastu gniewnych ludzi", "Sidney Lumet", 1957, 96);

            catalogue.Add(movie);

            Movie findMovie = catalogue.FindMovieByDirectorAndTitle("Sidney Lumet", "Dwunastu gniewnych ludzi");

            Assert.AreSame(movie, findMovie);
        }
        public void FindJournalByTitleAndNoTest()
        {
            Catalogue catalogue = new Catalogue();
            Journal   journal   = new Journal("Wnętrza Inspiracje", "Czasopisma krajowe", 2019, 3, 40, "Kuchnia w salonie");

            catalogue.Add(journal);

            Journal findJournal = catalogue.FindJournalByTitleAndNo("Wnętrza Inspiracje", 3);

            Assert.AreSame(journal, findJournal);
        }
예제 #14
0
        protected override void Execute(Catalogue catalogue, string[] eventNames)
        {
            foreach (var eventName in eventNames)
            {
                var eventType = catalogue.EventTypes[eventName];
                if (eventType == null)
                {
                    catalogue.Add(catalogue.CreateEventType(catalogue, eventName, false));
                }
                else
                {
                    eventType.IsEnabled = false;
                }
            }

            catalogue.Commit();
        }
예제 #15
0
        private void AssembleArtifacts(Catalogue catalogue, Assembler assembler, IEnumerable <KeyValuePair <string, Artifact> > artifacts, Action action)
        {
            // Iterate over each artifact.

            foreach (KeyValuePair <string, Artifact> pair in artifacts)
            {
                string   sourcePath = pair.Key;
                Artifact artifact   = pair.Value;

                // Determine the paths for the artifact.

                string sourceFullPath      = GetSourceFullPath(sourcePath);
                string destinationFullPath = GetDestinationFullPath(artifact);

                // Assemble it.

                assembler.AssembleArtifact(artifact, action, sourceFullPath, destinationFullPath);
                catalogue.Add(artifact);
            }
        }
예제 #16
0
        private static void CopyElement(Catalogue catalogue, EventType eventType)
        {
            // Check whether the event already exists.

            EventType thisEventType = catalogue.EventTypes[eventType.Name];

            if (thisEventType == null)
            {
                // Doesn't exist so create new clone.

                thisEventType = eventType.CloneProperties(catalogue, eventType.Name);
                catalogue.Add(thisEventType);
            }
            else
            {
                // Already exists so copy details.

                thisEventType.CopyProperties(eventType);
            }
        }