public void AddBookTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);
            Book book = new Book("H.P. Lovecraft", "Call of Cthulhu", 623);

            dataRepository.AddBook(book);
            Assert.AreEqual(dataContext.books[book.KeyNumber], book);
        }
        public void GetClientTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Client client = new Client("Janusz", "Tracz", "128945");

            dataContext.clients.Add(client);
            Assert.AreEqual(dataRepository.GetClient(dataContext.clients.Count - 1), client);
        }
        public void GetBookStateTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Book      book      = new Book("Tom", "C#Start", 455);
            BookState bookState = new BookState(book, 10, 23.5f, 23, "ORA");

            dataContext.bookStates.Add(bookState);
            Assert.AreEqual(dataRepository.GetBookState(dataContext.bookStates.Count - 1), bookState);
        }
        public void GetEventTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Client         client    = new Client("Ala", "Kot", "2234");
            Book           book      = new Book("J R R Tolkien", "Hobbit", 1);
            DateTimeOffset date      = new DateTimeOffset(new DateTime(2019, 10, 15));
            BookState      bookState = new BookState(book, 5, 45.3f, 10, "XRA");
            Event          saleEvent = new Sale(client, bookState, date, 2);

            dataContext.events.Add(saleEvent);
            Assert.AreEqual(dataRepository.GetEvent(dataContext.events.Count - 1), saleEvent);
        }
        public void DeleteClientTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Client client = new Client("Janusz", "Tracz", "128945");

            dataContext.clients.Add(client);
            int size1 = dataContext.clients.Count();

            Assert.IsTrue(dataContext.clients.Contains(client));
            dataRepository.DeleteClient(client);
            Assert.AreEqual(dataContext.clients.Count, size1 - 1);
            Assert.IsFalse(dataContext.clients.Contains(client));
        }
        public void DeleteBookTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Book book = new Book("H.P. Lovecraft", "Call of Cthulhu", 623);

            dataContext.books.Add(book.KeyNumber, book);
            int size1 = dataContext.books.Count();

            Assert.IsTrue(dataContext.books.ContainsValue(book));
            dataRepository.DeleteBook(book.KeyNumber);
            Assert.AreEqual(dataContext.books.Count, size1 - 1);
            Assert.IsFalse(dataContext.books.ContainsValue(book));
        }
        public void DeleteBookStateTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Book      book      = new Book("Tom", "C#Start", 455);
            BookState bookState = new BookState(book, 10, 23.5f, 23, "ORA");

            dataContext.bookStates.Add(bookState);
            int size1 = dataContext.bookStates.Count();

            Assert.IsTrue(dataContext.bookStates.Contains(bookState));
            dataRepository.DeleteBookState(bookState);
            Assert.AreEqual(dataContext.bookStates.Count, size1 - 1);
            Assert.IsFalse(dataContext.bookStates.Contains(bookState));
        }
        public void GetAllBookStatesTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            List <BookState> list  = (dataRepository.GetAllBookStates()).ToList();
            List <BookState> list2 = new List <BookState>();

            list2.Add(new BookState(dataContext.books[686], 10, 27.59f, 23, "XRA"));
            list2.Add(new BookState(dataContext.books[524], 5, 30.49f, 23, "35D"));
            list2.Add(new BookState(dataContext.books[125], 10, 39.99f, 23, "45Z"));
            list2.Add(new BookState(dataContext.books[666], 10, 21.99f, 23, "15T"));
            Assert.AreEqual(list.Count(), list2.Count);
            for (int i = 0; i < list.Count(); i++)
            {
                Assert.AreEqual(list[i], list2[i]);
            }
        }
        public void GetAllClientsTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            List <Client> list  = (dataRepository.GetAllClients()).ToList();
            List <Client> list2 = new List <Client>();

            list2.Add(new Client("John", "Hancock", "216834"));
            list2.Add(new Client("Holy", "Hancock", "215912"));
            list2.Add(new Client("John", "Smith", "217632"));
            list2.Add(new Client("Holy", "Smith", "216143"));
            Assert.AreEqual(list.Count(), list2.Count);
            for (int i = 0; i < list.Count(); i++)
            {
                Assert.AreEqual(list[i], list2[i]);
            }
        }
        public void GetAllBooksTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            List <Book> list  = (dataRepository.GetAllBooks()).ToList();
            List <Book> list2 = new List <Book>();

            list2.Add(new Book("Michelle Obama", "Becoming", 686));
            list2.Add(new Book("Tara Westover", "Tara Westover", 524));
            list2.Add(new Book("Mark R. Levin", "Unfreedom of the Press", 125));
            list2.Add(new Book("Jake Richards", "Backwoods Witchcraft", 666));
            Assert.AreEqual(list.Count(), list2.Count);
            for (int i = 0; i < list.Count(); i++)
            {
                Assert.AreEqual(list[i], list2[i]);
            }
        }
        public void GetAllEventsTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            List <Event> list  = (dataRepository.GetAllEvents()).ToList();
            List <Event> list2 = new List <Event>();

            list2.Add(new Purchase(dataContext.clients[0], dataContext.bookStates[0], new DateTime(2019, 10, 15), 10));
            list2.Add(new Purchase(dataContext.clients[1], dataContext.bookStates[1], new DateTime(2019, 10, 12), 8));
            list2.Add(new Purchase(dataContext.clients[0], dataContext.bookStates[2], new DateTime(2019, 10, 11), 7));
            list2.Add(new Purchase(dataContext.clients[1], dataContext.bookStates[3], new DateTime(2019, 10, 9), 6));

            list2.Add(new Sale(dataContext.clients[2], dataContext.bookStates[1], new DateTime(2019, 10, 21), 1));
            list2.Add(new Sale(dataContext.clients[3], dataContext.bookStates[0], new DateTime(2019, 10, 1), 4));
            list2.Add(new Sale(dataContext.clients[0], dataContext.bookStates[3], new DateTime(2019, 10, 5), 1));
            list2.Add(new Sale(dataContext.clients[2], dataContext.bookStates[3], new DateTime(2019, 10, 7), 2));
            Assert.AreEqual(list.Count(), list2.Count);
            for (int i = 0; i < list.Count(); i++)
            {
                Assert.AreEqual(list[i], list2[i]);
            }
        }