Esempio n. 1
0
        public void AddClientTest()
        {
            // valid argument
            Client client1 = new Client("Hermenegilda", "Kowalska", "*****@*****.**", "Łódź Piotrkowska 35", "+48123123123");

            dataRepository.AddClient(client1);
            Assert.AreEqual(6, dataRepository.GetAllClients().Count());
            Assert.AreEqual(client1, dataRepository.GetAllClients().Last());

            // argument exception
            Client client2 = new Client("Zofia", "Nowak", "*****@*****.**", "Pabianice Zamkowa 23c", "+48123456782");

            Assert.ThrowsException <ArgumentException>(() => dataRepository.AddClient(client2));
        }
Esempio n. 2
0
        public void Fill(IDataRepository dataRepository)
        {
            Client adam     = new Client("Adam", "Kowalski", 28);
            Client maciej   = new Client("Maciej", "Jankowski", 21);
            Client marta    = new Client("Marta", "Borkowska", 35);
            Client adrianna = new Client("Adrianna", "Sarna", 19);
            Client andrea   = new Client("Andrea", "Sovilile", 94);

            dataRepository.AddClient(adam);
            dataRepository.AddClient(maciej);
            dataRepository.AddClient(marta);
            dataRepository.AddClient(adrianna);
            dataRepository.AddClient(andrea);

            Book book1 = new Book("Uncle Tom's Cabin", "Harriet Beecher Stowe", CoverType.Paperback, "Mystery");
            Book book2 = new Book("Brainwalker", "Robyn Mundell", CoverType.Other, "Horror");
            Book book3 = new Book("Inferno", "Dante Alighieri", CoverType.HardcoverCaseWrap, "Science");
            Book book4 = new Book("The Shadow Girl", "Robyn Mundell", CoverType.HardcoverDustJacket, "Guide");
            Book book5 = new Book("Schindler's List", "Thomas Keneally", CoverType.Paperback, "History");

            dataRepository.AddBook(book1);
            dataRepository.AddBook(book2);
            dataRepository.AddBook(book3);
            dataRepository.AddBook(book4);
            dataRepository.AddBook(book5);

            BookState bookState1 = new BookState(book1, 30, 20);
            BookState bookState2 = new BookState(book2, 70, 67);
            BookState bookState3 = new BookState(book3, 50, 25);
            BookState bookState4 = new BookState(book4, 48, 57);
            BookState bookState5 = new BookState(book5, 25, 200);

            dataRepository.AddBookState(bookState1);
            dataRepository.AddBookState(bookState2);
            dataRepository.AddBookState(bookState3);
            dataRepository.AddBookState(bookState4);
            dataRepository.AddBookState(bookState5);

            Purchase purchase1 = new Purchase(adam, bookState1, DateTimeOffset.Now, 1);
            Purchase purchase2 = new Purchase(adam, bookState2, DateTimeOffset.Now, 32);
            Purchase purchase3 = new Purchase(maciej, bookState5, DateTimeOffset.Now, 100);
            Purchase purchase4 = new Purchase(adrianna, bookState4, DateTimeOffset.Now, 12);
            Purchase purchase5 = new Purchase(andrea, bookState1, DateTimeOffset.Now, 10);

            dataRepository.AddPurchase(purchase1);
            dataRepository.AddPurchase(purchase2);
            dataRepository.AddPurchase(purchase3);
            dataRepository.AddPurchase(purchase4);
            dataRepository.AddPurchase(purchase5);
        }
Esempio n. 3
0
        public Client AddClient(string name, string surname, string email, string city)
        {
            var client = new Client(name, surname, email, city);

            _dataRepository.AddClient(client);
            return(client);
        }
 void AddClient(string name, string lastname, DateTime birthday, string email)
 {
     _dataRepository.AddClient(new Client {
         Id       = new Guid(),
         Name     = name,
         LastName = lastname,
         Birthday = birthday,
         Email    = email
     });
 }
Esempio n. 5
0
        public void AddAndGetClient()
        {
            Client c = new Client("Paweł", "Burczyk", "7");

            Assert.AreEqual(repository.GetAllClientsNumber(), 4);
            repository.AddClient(c);
            Assert.AreEqual(repository.GetAllClientsNumber(), 5);
            Client temp = repository.GetClient("7");

            Assert.AreEqual(temp, c);
        }
Esempio n. 6
0
        public async Task <IActionResult> PostClient([FromBody] ClientRequest clientRequest, ApiVersion apiVersion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var client = new Client {
                Application     = clientRequest.Application,
                Audience        = clientRequest.Audience,
                AppGroupRegexes = clientRequest.AppGroupRegexes,
                CookieDomain    = clientRequest.CookieDomain ?? _settings.CookieDomain,
                CookiePath      = clientRequest.CookiePath ?? _settings.CookiePath,
                TokenName       = clientRequest.TokenName ?? _settings.TokenName,
                ApiKey          = Guid.NewGuid().ToString("N")
            };

            await _dataRepository.AddClient(client);

            return(CreatedAtAction(nameof(ClientController.GetClient), "client", new { id = client.Id, version = apiVersion.ToString() }, client));
        }
Esempio n. 7
0
 public void AddClient(string firstName, string lastName, long phoneNumber)
 {
     dataRepository.AddClient(new Client(firstName, lastName, phoneNumber, new Guid()));
 }
Esempio n. 8
0
 public void AddClient(Client client)
 {
     _dataRepository.AddClient(client);
 }
Esempio n. 9
0
 public void AddClient_Test_Successful()
 {
     _dataRepository.AddClient(_client);
     Assert.AreEqual(ClientNumber + 1, _dataRepository.GetAllClients().Count());
     Assert.AreSame(_client, _dataRepository.GetClient(_client.Email));
 }
Esempio n. 10
0
 public void AddClient(Client client)
 {
     repository.AddClient(client);
 }
Esempio n. 11
0
        public void AddClient(string name, string surname, string emailAddress, string address, string phoneNumber)
        {
            Client client = new Client(name, surname, emailAddress, address, phoneNumber);

            dataRepository.AddClient(client);
        }
Esempio n. 12
0
 public void CreateClient(string firstName, string lastName, int age)
 {
     dataRepository.AddClient(new Client(firstName, lastName, age));
 }