Esempio n. 1
0
        public void RemoveClientById_PassNonExistingClientId_ReturnsSameTable()
        {
            IClientDAL            clientDAL  = new ClientDAL(new DBService(new DbConnectionService(_connectionStringName)));
            IEnumerable <IClient> clientList = clientDAL.GetClients();
            int  oldCount        = clientList.Count();
            bool isClientDeleted = clientDAL.RemoveClientById(Guid.NewGuid());
            int  newCount        = clientDAL.GetClients().Count();

            Assert.IsTrue(!isClientDeleted && newCount == oldCount);
        }
Esempio n. 2
0
        public void RemoveClientById_PassExistingClientId_ReturnsTableWithoutDeletedClient()
        {
            IClientDAL            clientDAL  = new ClientDAL(new DBService(new DbConnectionService(_connectionStringName)));
            IEnumerable <IClient> clientList = clientDAL.GetClients();
            int  oldCount        = clientList.Count();
            bool isClientDeleted = clientDAL.RemoveClientById(DbSeeder.TestClientId);
            int  newCount        = clientDAL.GetClients().Count();

            Assert.IsTrue(isClientDeleted && newCount == oldCount - 1);
        }
Esempio n. 3
0
        public void AddClient_PassNewClient_ReturnsTableWithAddedClient()
        {
            IClientDAL            clientDAL  = new ClientDAL(new DBService(new DbConnectionService(_connectionStringName)));
            IEnumerable <IClient> clientList = clientDAL.GetClients();
            int  oldCount = clientList.Count();
            Guid id       = Guid.NewGuid();

            clientDAL.AddClient(new Client(id, "Namex"));
            List <IClient> newList          = clientDAL.GetClients().ToList();
            bool           isNewClientFound = newList.FindIndex(client => client.Id == id) > -1;

            Assert.IsTrue(isNewClientFound && newList.Count() == oldCount + 1);
        }
Esempio n. 4
0
        public void GetClients_GetClientsFromNonEmptyTable_ReturnsTableWithList()
        {
            IClientDAL     clientDAL  = new ClientDAL(new DBService(new DbConnectionService(_connectionStringName)));
            List <IClient> clientList = clientDAL.GetClients().ToList();

            Assert.IsTrue(clientList.Count() == DbSeeder.clientList.Count());
        }
Esempio n. 5
0
        public void GetClients_GetClientsFromEmptyTable_ReturnsEmptyTable()
        {
            _dbSeeder.EmptyTables();
            IClientDAL            clientDAL  = new ClientDAL(new DBService(new DbConnectionService(_connectionStringName)));
            IEnumerable <IClient> clientList = clientDAL.GetClients();

            Assert.IsTrue(clientList.Count() == 0);
        }
Esempio n. 6
0
        public void UpdateClientById_PassValidClientObject_ReturnsTableWithUpdatedClient()
        {
            IClientDAL clientDAL = new ClientDAL(new DBService(new DbConnectionService(_connectionStringName)));
            IClient    newClient = new Client(DbSeeder.TestClientId, "Foo", "Addr");

            clientDAL.UpdateClientById(newClient);
            List <IClient> updatedList   = clientDAL.GetClients().ToList();
            IClient        updatedClient = updatedList.Find(client => client.Id == DbSeeder.TestClientId);

            Assert.IsTrue(updatedClient.Name == "Foo" && updatedClient.Address == "Addr");
        }
Esempio n. 7
0
 internal ObservableCollection <Client> GetAllClients()
 {
     return(clientDAL.GetClients());
 }