public void GetWykazByKategoriaGryTest() { string imie1 = "Imie1"; string imie2 = "Imie2"; string nazwisko1 = "Nazwisko1"; string nazwisko2 = "Nazwisko2"; string kategoriaGry1 = "kategoriaGry1"; string kategoriaGry2 = "kategoriaGry2"; string nazwaGry1 = "nazwaGry1"; string nazwaGry2 = "nazwaGry2"; string autorGry1 = "autorGry1"; string autorGry2 = "autorGry2"; string opisGry1 = "opisGry1"; string opisGry2 = "opisGry2"; IFillingColection fillingColection = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); DataRepository dataRepository = new DataRepository(fillingColection, dataContext); DataService dataService = new DataService(dataRepository); Wykaz wykaz1 = new Wykaz(imie1, nazwisko1, 1, new System.DateTime(2018, 11, 1)); Wykaz wykaz2 = new Wykaz(imie2, nazwisko2, 2, new System.DateTime(2018, 11, 2)); Katalog katalog1 = new Katalog(1, kategoriaGry1); Katalog katalog2 = new Katalog(2, kategoriaGry2); OpisStanu opisStanu1 = new OpisStanu(katalog1, nazwaGry1, autorGry1, opisGry1); OpisStanu opisStanu2 = new OpisStanu(katalog2, nazwaGry2, autorGry2, opisGry2); Zdarzenie zdarzenie1 = new Zdarzenie(1, wykaz1, opisStanu1); Zdarzenie zdarzenie2 = new Zdarzenie(2, wykaz2, opisStanu2); dataRepository.AddZdarzenie(zdarzenie1); dataRepository.AddZdarzenie(zdarzenie2); CollectionAssert.Equals(imie1, dataService.GetWykazByKategoriaGry(kategoriaGry1)[0].Imie); }
public void TestAddRepository() { DataFiller dataFiller = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); DataRepository dataRepository = new DataRepository(dataFiller) { DataContext = dataContext }; dataRepository.Fill(); // Test for add vehicle Vehicle newVehicle = new Vehicle() { Registration = "WA 77777", VehicleBrand = "Lamborghini", VehicleModel = "Usus" }; Assert.AreEqual(dataRepository.GetAllVehicleEnumerable().Count(), 7); dataRepository.AddVehicle(newVehicle); Assert.AreEqual(dataRepository.GetAllVehicleEnumerable().Count(), 8); //Test for add Client Client newClient = new Client() { FirstName = "Adrian", LastName = "Michalak", Age = 19, Pesel = "2323425982" }; Assert.AreEqual(dataRepository.GetAllCLientsEnumerable().Count(), 5); dataRepository.AddClient(newClient); Assert.AreEqual(dataRepository.GetAllCLientsEnumerable().Count(), 6); //Test for add VehicleStatus VehicleState newVehicleStatus = new VehicleState() { Vehicle = newVehicle, Avaiable = false, RentalPrice = 2000 }; Assert.AreEqual(dataRepository.GetAllVehicleStateIEnumerable().Count(), 6); dataRepository.AddVehicleState(newVehicleStatus); Assert.AreEqual(dataRepository.GetAllVehicleStateIEnumerable().Count(), 7); Event newEvent = new Event() { Client = newClient, VehicleState = newVehicleStatus, RentalOfDate = new DateTimeOffset(2018, 02, 22, 12, 0, 0, new TimeSpan(1, 0, 0)), ReturnOfDate = new DateTimeOffset(2018, 04, 09, 13, 0, 0, new TimeSpan(1, 0, 0)) }; Assert.AreEqual(dataRepository.GetAllEventEnumerable().Count(), 5); dataRepository.AddEvent(newEvent); Assert.AreEqual(dataRepository.GetAllEventEnumerable().Count(), 6); }
public void GetAllZdarzeniaDlaKsiazkiTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); DataService dataService = new DataService(dataRepository); Ksiazka ksiazka = new Ksiazka("Testowa", "Ksiazka1"); dataService.AddKsiazka(ksiazka); Stan stan = new Stan(ksiazka, "", false); dataService.AddStan(stan); Assert.AreEqual(0, dataService.GetAllZdarzeniaDlaKsiazki(stan.Ksiazka).Count()); dataService.WypozyczKsiazke(dataService.GetKlient(0), stan); Assert.AreEqual(1, dataService.GetAllZdarzeniaDlaKsiazki(stan.Ksiazka).Count()); dataService.ZwrocKsiazke(dataService.GetKlient(0), stan); Assert.AreEqual(2, dataService.GetAllZdarzeniaDlaKsiazki(stan.Ksiazka).Count()); dataService.WypozyczKsiazke(dataService.GetKlient(0), stan); Assert.AreEqual(3, dataService.GetAllZdarzeniaDlaKsiazki(stan.Ksiazka).Count()); }
public void WypozyczKsiazkeTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); DataService dataService = new DataService(dataRepository); Klient klient1 = new Klient("Jan", "Nazwisko1"); Klient klient2 = new Klient("Jan", "Nazwisko2"); Ksiazka ksiazka1 = new Ksiazka("Tytul", "Autor1"); Ksiazka ksiazka2 = new Ksiazka("Tytul", "Autor2"); Stan stan1 = new Stan(ksiazka1, "Opis1", false); Stan stan2 = new Stan(ksiazka2, "Opis2", false); dataService.AddStan(stan1); dataService.AddStan(stan2); dataService.WypozyczKsiazke(klient1, stan1); Assert.ThrowsException <ArgumentException>(() => dataService.WypozyczKsiazke(klient2, stan1)); dataService.WypozyczKsiazke(klient2, stan2); Assert.ThrowsException <ArgumentException>(() => dataService.WypozyczKsiazke(klient2, stan2)); Assert.AreEqual(1, dataService.GetAllZdarzeniaDlaKlienta(klient1).ToList().Count); Assert.AreEqual(1, dataService.GetAllZdarzeniaDlaKlienta(klient2).ToList().Count); Assert.AreEqual(1, dataService.GetAllZdarzeniaDlaStanu(stan1).ToList().Count); Assert.AreEqual(1, dataService.GetAllZdarzeniaDlaStanu(stan2).ToList().Count); }
public void GetAllClientsTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Assert.AreEqual(DR.GetAllClients(), DR.GetAllClients()); }
public void GetCopyTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Assert.AreEqual(DR.GetCopy(3), DR.GetAllCopies()[3]); }
public void GetAllCopiesTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Assert.AreEqual(DR.GetAllCopies().Count, 5); }
public void GetAllStanyDlaKsiazkiTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); DataService dataService = new DataService(dataRepository); Klient klient = new Klient("Jan", "Kowalski"); dataService.AddKlient(klient); Ksiazka ksiazka = new Ksiazka("Testowa", "Ksiazka1"); dataService.AddKsiazka(ksiazka); Assert.AreEqual(0, dataService.GetAllStanyDlaKsiazki(ksiazka).Count()); dataService.AddStan(new Stan(ksiazka, "", false)); Assert.AreEqual(1, dataService.GetAllStanyDlaKsiazki(ksiazka).Count()); dataService.AddStan(new Stan(ksiazka, "", false)); Assert.AreEqual(2, dataService.GetAllStanyDlaKsiazki(ksiazka).Count()); dataService.AddStan(new Stan(ksiazka, "", false)); Assert.AreEqual(3, dataService.GetAllStanyDlaKsiazki(ksiazka).Count()); }
public void GetInvoiceTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Assert.AreEqual(DR.GetInvoice(1), DR.GetAllInvoices()[1]); }
public void FindInStanyTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); DataService dataService = new DataService(dataRepository); String query = "Witaj Swiecie"; Ksiazka ksiazka = new Ksiazka("Witaj Swiecie", "Jan"); dataService.AddKsiazka(ksiazka); Assert.AreEqual(0, dataService.FindInStany(query).Count()); dataService.AddStan(new Stan(ksiazka, "", false)); Assert.AreEqual(1, dataService.FindInStany(query).Count()); dataService.AddStan(new Stan(dataService.GetKsiazka(0), "Witaj Swiecie", false)); dataService.AddStan(new Stan(dataService.GetKsiazka(0), "", true)); Assert.AreEqual(2, dataService.FindInStany(query).Count()); dataService.AddStan(new Stan(ksiazka, "Witaj Swiecie", false)); Assert.AreEqual(3, dataService.FindInStany(query).Count()); }
public void UpdateKlientExceptionTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); Assert.ThrowsException <KeyNotFoundException>(() => dataRepository.UpdateKlient(dataRepository.GetAllKlient().Count() + 1, "Jan", "Kowalski")); }
public void GetZdarzenieExceptionTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); Assert.ThrowsException <KeyNotFoundException>(() => dataRepository.GetZdarzenie(dataRepository.GetAllZdarzenie().Count() + 1)); }
public void UpdateKsiazkaTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); dataRepository.UpdateKsiazka(0, "UpdateTytul", "UpdateAutor"); Assert.AreEqual("UpdateAutor", dataRepository.GetKsiazka(0).Autor); Assert.AreEqual("UpdateTytul", dataRepository.GetKsiazka(0).Tytul); }
public void UpdateKlientTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); dataRepository.UpdateKlient(0, "Karol", "Update"); Assert.AreEqual("Karol", dataRepository.GetKlient(0).Imie); Assert.AreEqual("Update", dataRepository.GetKlient(0).Nazwisko); }
public void AddCopyTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Egzemplarz E1 = new Egzemplarz(9.99, "AAA", new DateTime(2009), null); DR.AddCopy(E1); Assert.AreEqual(E1, DR.GetCopy(5)); }
public void AddClientTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Klient K1 = new Klient("AAA", "BBB", 10); DR.AddClient(K1); Assert.AreEqual(K1, DR.GetClient(5)); }
public void DeleteStanAlreadyUsedExceptionTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); Stan stan = dataRepository.GetStan(0); Zdarzenie zdarzenie = new Wypozyczenie(dataRepository.GetKlient(0), stan); Assert.ThrowsException <Exception>(() => dataRepository.DeleteStan(stan)); }
public void WypelnianieStalymiTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); Assert.AreEqual(10, dataContext.Klienci.Count); Assert.AreEqual(10, dataContext.Ksiazki.Count); Assert.AreEqual(10, dataContext.Stany.Count); Assert.AreEqual(20, dataContext.Zdarzenia.Count); }
public void GetKsiazkaTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); for (int i = 0; i < dataContext.Ksiazki.Count; i++) { Assert.AreEqual("TestowyTytul" + i, dataRepository.GetKsiazka(i).Tytul); Assert.AreEqual("TestowyAutor" + i, dataRepository.GetKsiazka(i).Autor); } }
public void DeleteInvoiceByPositionTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Faktura BackUp = DR.GetInvoice(1); DR.DeleteInvoice(1); Assert.AreEqual(DR.GetAllInvoices().Count, 2); Assert.AreNotEqual(DR.GetInvoice(1), BackUp); }
public void DeleteCopyByPositionTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Egzemplarz BackUp = DR.GetCopy(3); DR.DeleteCopy(3); Assert.AreEqual(DR.GetAllCopies().Count, 4); Assert.AreNotEqual(DR.GetCopy(3), BackUp); }
public void DeleteClientByPositionTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Klient BackUp = DR.GetClient(3); DR.DeleteClient(3); Assert.AreEqual(DR.GetAllClients().Count, 4); Assert.AreNotEqual(DR.GetClient(3), BackUp); }
public void GetBookTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Guid ID = System.Guid.NewGuid(); Ksiazka K1 = new Ksiazka(ID, "Tytul", "Autor"); DR.AddBook(K1); Assert.AreEqual(DR.GetBook(ID), K1); }
public void DeleteBookTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Guid ID = System.Guid.NewGuid(); Ksiazka K1 = new Ksiazka(ID, "Tytul", "Autor"); DR.DeleteBook(ID); Assert.AreEqual(DR.GetAllBooks().Count, 5); }
public void AddInvoiceTest() { DataFiller DF = new WypelnianieStalymi(); DataRepository DR = new DataRepository(DF); Faktura F1 = new Faktura(new DateTime(2009), null, null); DR.AddInvoice(F1); Assert.AreEqual(F1, DR.GetInvoice(3)); }
public void GetKlientTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); for (int i = 0; i < dataContext.Klienci.Count; i++) { Assert.AreEqual("Jan" + i, dataRepository.GetKlient(i).Imie); Assert.AreEqual("Testowy" + i, dataRepository.GetKlient(i).Nazwisko); } }
public void DeleteKsiazkaExceptionTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); Ksiazka ksiazka = dataRepository.GetKsiazka(0); dataRepository.AddStan(new Stan(ksiazka, "", false)); Assert.AreSame(ksiazka, dataRepository.GetKsiazka(0)); Assert.ThrowsException <Exception>(() => dataRepository.DeleteKsiazka(ksiazka)); }
public void FillCollectionTest() { string imie1 = "Imie1"; IFillingColection fillingColection = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); DataRepository dataRepository = new DataRepository(fillingColection, dataContext); dataRepository.FillColection(dataContext); Assert.AreEqual(imie1, dataRepository.DataContext.listaWykazow[0].Imie); CollectionAssert.AllItemsAreNotNull(dataRepository.DataContext.listaWykazow); }
public void AddKatalogTest() { string kategoriaGry1 = "kategoriaGry1"; IFillingColection fillingColection = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); DataRepository dataRepository = new DataRepository(fillingColection, dataContext); Katalog katalog1 = new Katalog(1, kategoriaGry1); dataRepository.AddKatalog(1, katalog1); Assert.AreEqual(kategoriaGry1, dataContext.listaKatalogow[1].KategoriaGry); }
public void GetStanTest() { IDataFiller wypelnianieStalymi = new WypelnianieStalymi(); DataContext dataContext = new DataContext(); IDataRepository dataRepository = new DataRepository(wypelnianieStalymi, dataContext); for (int i = 0; i < dataContext.Stany.Count; i++) { Assert.AreEqual(dataContext.Ksiazki[i], dataRepository.GetStan(i).Ksiazka); Assert.AreEqual("TestowyOpis" + i, dataRepository.GetStan(i).Opis); Assert.AreEqual(new DateTime(2020, 10, i + 1, 13, i + 1, 30), dataRepository.GetStan(i).DataZakupu); } }