Beispiel #1
0
        public void AddAndGetClient()
        {
            Client c = new Client("Paweł", "Burczyk", "6");

            Assert.AreEqual(service.GetAllClientsNumber(), 4);
            service.AddClient(c);
            Assert.AreEqual(service.GetAllClientsNumber(), 5);
            Client temp = service.GetClientById("6");

            Assert.AreEqual(temp, c);
        }
Beispiel #2
0
        public void GetAllClientsTest()
        {
            DataRepository dataRepository = new DataRepository();
            DataService    dataService    = new DataService(dataRepository);

            dataService.AddClient(new Client("Ellie", "Doe", "21151112115", "111112115"));
            dataService.AddClient(new Client("Luis", "Snow", "21152222115", "222222115"));
            dataService.AddClient(new Client("Rachel", "Sanchez", "21153332115", "333332115"));
            dataService.AddClient(new Client("Jud", "Smith", "21154442115", "444442115"));
            dataService.AddClient(new Client("Gage", "Butler", "21155552115", "555552115"));

            Assert.AreEqual(5, dataService.GetAllClients().Count());
            Assert.IsInstanceOfType(dataService.GetAllClients(), typeof(IEnumerable <Client>));
        }
Beispiel #3
0
        public void AddClientTest()
        {
            DataRepository dataRepository = new DataRepository();
            DataService    dataService    = new DataService(dataRepository);
            Client         client         = new Client("ClName", "ClLastName", "99101023432", "321654987");

            Assert.AreEqual(dataService.GetAllClients().Count(), 0);
            dataService.AddClient(client);
            Assert.AreEqual(dataService.GetAllClients().Count(), 1);
        }
Beispiel #4
0
        public void RentNotEnoughBooksExceptionTest()
        {
            DataService dataService = new DataService();
            string      catalogID   = "1";
            string      clientID    = "11";

            dataService.AddCatalog(catalogID, "Pan Tadeusz", "Adam Mickiewicz");
            dataService.AddInventory(catalogID, 0);
            dataService.AddClient(clientID, "Jan", "Kowalski");
            InvalidOperationException e = Assert.ThrowsException <InvalidOperationException>(() => dataService.RentBook(clientID, catalogID));
//            Console.WriteLine(e.Message);
        }
Beispiel #5
0
        public void AddClientTest()
        {
            IDataFiller     constantDataFiller = new ConstantDataFiller();
            IDataRepository dataRepository     = new DataRepositoryForTest(constantDataFiller);
            IDataService    dataService        = new DataService(dataRepository);

            Client client = new Client("*****@*****.**", "Michał", "Kopytko", "8462");

            int clientsNumber = dataService.GetClients().ToImmutableHashSet().Count;

            dataService.AddClient(client);
            Assert.Equal(clientsNumber + 1, dataService.GetClients().ToImmutableHashSet().Count);
            Assert.Equal(client, dataService.GetClients().Last());
        }
Beispiel #6
0
        public void PenaltyTest()
        {
            DataService dataService = new DataService();
            string      catalogID   = "1";
            string      clientID    = "11";

            dataService.AddCatalog(catalogID, "Pan Tadeusz", "Adam Mickiewicz");
            dataService.AddInventory(catalogID, 5);
            dataService.AddClient(clientID, "Jan", "Kowalski");
            dataService.RentBook(clientID, catalogID);
            Assert.AreEqual(0, dataService.PenaltySumForAllClients());
            dataService.ProlongRent(dataService.EventsForClient(clientID)[0].ID, -8);
            dataService.ReturnBook(clientID, catalogID);
            Assert.AreEqual(1, dataService.PenaltySumForAllClients());
        }
Beispiel #7
0
        public void DeleteClientTest()
        {
            IDataFiller     constantDataFiller = new ConstantDataFiller();
            IDataRepository dataRepository     = new DataRepositoryForTest(constantDataFiller);
            IDataService    dataService        = new DataService(dataRepository);

            Client client = new Client("michu_one_two_three", "Mich", "Kasztanek", "1234");

            dataService.AddClient(client);

            int originalCount = dataService.GetClients().ToImmutableHashSet().Count;

            dataService.DeleteClient(client);

            Assert.Equal(originalCount - 1, dataService.GetClients().ToImmutableHashSet().Count);
            Assert.DoesNotContain(client, dataService.GetClients());
        }
Beispiel #8
0
        public void GetPurchasesForClientTest()
        {
            DataRepository dataRepository = new DataRepository();
            DataService    dataService    = new DataService(dataRepository);
            Book           book           = new Book("Something Fishy", "Wodehouse", 1957);
            BookDetails    bookDetails    = new BookDetails(book, new decimal(12.99), new decimal(0.05), 12, "Something Fishy is a novel by P. G. Wodehouse, first published in the United Kingdom on 18 January 1957 by Herbert Jenkins, London and in the United States on 28 January 1957 by Simon & Schuster, Inc., New York, under the title The Butler Did It.");
            Client         client         = new Client("ClName", "ClLastName", "99101023432", "321654987");

            dataService.AddClient(client);
            dataService.AddBook(book);
            dataService.AddBookDetails(bookDetails);
            dataService.SellBook(client, bookDetails, 10);

            CollectionAssert.AreEqual(new List <Purchase> {
                dataService.GetPurchase(0)
            }, dataService.GetPurchasesForClient(dataService.GetClient(0)).ToList());
        }
Beispiel #9
0
        public void RentTest()
        {
            DataService dataService = new DataService();
            string      catalogID   = "1";
            string      clientID    = "11";

            dataService.AddCatalog(catalogID, "Pan Tadeusz", "Adam Mickiewicz");
            dataService.AddInventory(catalogID, 5);
            dataService.AddClient(clientID, "Jan", "Kowalski");
            Assert.AreEqual(5, dataService.NumberOfBooks(catalogID));
            Assert.AreEqual(0, dataService.CurrentlyRentedBooksNumber(clientID));
            Assert.AreEqual(0, dataService.EventsForClient(clientID).Count);
            dataService.RentBook(clientID, catalogID);
            Assert.AreEqual(4, dataService.NumberOfBooks(catalogID));
            Assert.AreEqual(1, dataService.CurrentlyRentedBooksNumber(clientID));
            Assert.AreEqual(1, dataService.EventsForClient(clientID).Count);
        }
Beispiel #10
0
        public void RentExceededPenaltyExceptionTest()
        {
            DataService dataService = new DataService();
            string      catalogID   = "1";
            string      catalogID2  = "2";
            string      clientID    = "11";

            dataService.AddCatalog(catalogID, "Pan Tadeusz", "Adam Mickiewicz");
            dataService.AddInventory(catalogID, 5);
            dataService.AddCatalog(catalogID2, "Krzyzacy", "Henryk Sienkiewicz");
            dataService.AddInventory(catalogID2, 5);
            dataService.AddClient(clientID, "Jan", "Kowalski");
            dataService.RentBook(clientID, catalogID);
            dataService.ProlongRent(dataService.EventsForClient(clientID)[0].ID, -18);
            dataService.ReturnBook(clientID, catalogID);
            InvalidOperationException e = Assert.ThrowsException <InvalidOperationException>(() => dataService.RentBook(clientID, catalogID2));
//            Console.WriteLine(e.Message);
        }
Beispiel #11
0
 public void AddClient_Test_Succesful()
 {
     Assert.AreEqual(_c1.Email, _dataService.AddClient(_c1.Name, _c1.Surname, _c1.Email, _c1.City).Email);
 }
Beispiel #12
0
 public void AddClientTest()
 {
     Assert.AreEqual(0, dataService.GetAllClients().Count());
     dataService.AddClient("Andrzej", "Nowak", 123456789);
     Assert.AreEqual(1, dataService.GetAllClients().Count());
 }