Ejemplo n.º 1
0
        public void TestDocumentManager()
        {
            var dm = new DocumentManager <Document>();

            dm.Add(new Document("Title A", "Sample A"));
            dm.Add(new Document("Title B", "Sample B"));

            string str = dm.DisplayAll();

            if (dm.IsAvailable)
            {
                str = dm.Get().Content;
            }
        }
        public void Given_a_user_who_uploads_a_document_store_the_document_in_the_document_queue()
        {
            //Arrange
            Document document = new();
            var      value    = 2;
            var      key      = nameof(value);

            document[key] = value;

            //Act
            DocumentManager.Add(document);

            //Assert
            AreEqual(1, DocumentManager.Documents.Count);
            AreEqual(value, DocumentManager.Documents.First()[key]);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            DocumentManager documentManagement = new DocumentManager();
            Book            book      = new Book("aaa", "tytul", new DateTime(1450, 5, 1), 2, "Patryk");
            Book            book2     = new Book("aab", "tytul2", new DateTime(2020, 5, 1), 2, "Patryk");
            Magazine        magazine  = new Magazine("aac", "tytul", new DateTime(2020, 5, 1), 100, 1, Magazine.Frequency.weekly);
            Magazine        magazine2 = new Magazine("aad", "tytul", new DateTime(2020, 5, 1), 100, 1, Magazine.Frequency.weekly);
            Volume          volume    = new Volume("aae", "tytul", new DateTime(2020, 5, 1), 100, "autor", 1, 10);
            Volume          volume2   = new Volume("aaf", "tytul", new DateTime(2020, 5, 1), 100, "autor", 1, 10);

            try
            {
                documentManagement.Add(book);
                documentManagement.Add(book2);
                documentManagement.Add(magazine);
                documentManagement.Add(magazine2);
                documentManagement.Add(volume);
                documentManagement.Add(volume2);
            }
            catch (NumberOfVolumeException e)
            {
                ExceptionDetails.Details(e);
            }
            catch (VolumeExistsException e)
            {
                ExceptionDetails.Details(e);
            }
            catch (DokumentExistsException e)
            {
                ExceptionDetails.Details(e);
            }
            catch (DateException e)
            {
                ExceptionDetails.Details(e);
            }
            Console.WriteLine();

            bool continueDoWhile = true;
            char key;

            do
            {
                Console.WriteLine("==================================================");
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Wybierz opcję:", Console.ForegroundColor);
                //Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("1. Wyświetl wszystkie dokumenty.\n" +
                                  "2. Metoda usuwającą z listy dokument o wskazanym ISBN.\n" +
                                  "3. Metoda zwracająca z listy dokument o wskazanym ISBN.\n" +
                                  "4. Metoda zwracająca z listy dokumenty o wskazanym typie.\n" +
                                  "5. Metoda zwracającą listę czasopism o podanej częstotliwości .\n" +
                                  "8. Wyczyść konsolę.\n" +
                                  "9. Zakończ program.");



                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("Wybór: ", Console.ForegroundColor);
                key = Console.ReadLine()[0];
                string type;

                switch (key)
                {
                case '1':
                    ShowAll(documentManagement);
                    Console.WriteLine();
                    break;

                case '2':
                    Console.Write("Podaj typ dokumentu: ");
                    type = Console.ReadLine();
                    Remove(documentManagement, type);
                    Console.WriteLine();
                    break;

                case '3':
                    Console.Write("Podaj tytul: ");
                    type = Console.ReadLine();
                    ShowISBN(documentManagement, type);
                    Console.WriteLine();
                    break;

                case '4':
                    Console.Write("Podaj tytul: ");
                    type = Console.ReadLine();
                    ShowDocuments(documentManagement, type);
                    Console.WriteLine();
                    break;

                case '5':
                    Console.Write("Podaj czestotliwosc: ");
                    type = Console.ReadLine();
                    Magazine.Frequency MyStatus = (Magazine.Frequency)Enum.Parse(typeof(Magazine.Frequency), type, true);
                    GetMagazines(documentManagement, MyStatus);
                    Console.WriteLine();
                    break;

                case '8':
                    Console.Clear();
                    Console.WriteLine();
                    break;

                case '9':
                    Console.WriteLine("Koniec programu");
                    continueDoWhile = false;
                    break;

                default:
                    continueDoWhile = true;
                    break;
                }
            } while (continueDoWhile);

            /*
             * foreach (Document item in documentManagement.ListOfDocuments)
             * {
             *  Console.WriteLine(item.GetType().FullName);
             * }
             */

            //documentManagement.GetAllDocuments().ForEach(x => Console.WriteLine(x.ToString()+"\n"));
            //documentManagement.GetVolumes("tytul").ForEach(x => Console.WriteLine(x.ToString() + "\n"));
        }