コード例 #1
0
        public void GetByFeatureClient()
        {
            List <Client> getByFeature;

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                ClearTable.KeyFeatures(db);
                ClearTable.Clients(db);
                ClearTable.KeyFeatureClients(db);

                clientL = Get(db);
                db.Features.AddRange(CreateListEntities.Features());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.Clients.AddRange(CreateListEntities.Clients());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                getByFeature = clientL.GetByFeature(new Feature
                {
                    Id     = 1,
                    Number = 1,
                    Name   = "qwe",
                });
            }

            CollectionAssert.AreEqual(getByFeature, CreateListEntities.Clients());
        }
コード例 #2
0
        public void GetByClientHaspKey()
        {
            List <HaspKey> getByClient;
            var            getByClientExpected = new List <HaspKey>
            {
                CreateNew(1),
            };

            var client = new Client
            {
                Id   = 1,
                Name = "Ivanov Ivan",
            };

            using (var db = new EntitesContext())
            {
                ClearTable.HaspKeys(db);
                ClearTable.KeyFeatures(db);
                ClearTable.KeyFeatureClients(db);

                haspKeyDAO = new DbHaspKeyDAO(db);
                db.HaspKeys.AddRange(CreateListEntities.HaspKeys());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                getByClient = haspKeyDAO.GetByClient(client);
            }

            CollectionAssert.AreEqual(getByClient, getByClientExpected);
        }
コード例 #3
0
        public void RemoveKeyFeatureClient()
        {
            bool remove;

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatureClients(db);

                keyFeatureClientL = Get(db);
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                remove = keyFeatureClientL.Remove(1);
            }

            Assert.IsTrue(remove);
        }
コード例 #4
0
        public void GetAllKeyFeatureClient()
        {
            var getAll     = new List <KeyFeatureClient>();;
            var keyFeatCls = CreateListEntities.KeyFeatureClients();

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatureClients(db);
                keyFeatureClientL = Get(db);
                foreach (var kfc in keyFeatCls)
                {
                    keyFeatureClientL.Save(kfc);
                }

                getAll = keyFeatureClientL.GetAll();
            }

            CollectionAssert.AreEqual(getAll, keyFeatCls);
        }
コード例 #5
0
        public void RemoveHaspKey()
        {
            bool remove;

            using (var db = new EntitesContext())
            {
                ClearTable.HaspKeys(db);
                ClearTable.KeyFeatures(db);
                ClearTable.KeyFeatureClients(db);

                haspKeyDAO = new DbHaspKeyDAO(db);
                db.HaspKeys.AddRange(CreateListEntities.HaspKeys());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                remove = haspKeyDAO.Remove(1);
            }

            Assert.IsTrue(remove);
        }
コード例 #6
0
        public void GetByNumberKeyClient()
        {
            Client getByNumberKey;
            Client actual = CreateListEntities.Clients()[0];

            using (var db = new EntitesContext())
            {
                ClearTable.HaspKeys(db);
                ClearTable.KeyFeatures(db);
                ClearTable.Clients(db);
                ClearTable.KeyFeatureClients(db);

                clientL = Get(db);
                db.HaspKeys.AddRange(CreateListEntities.HaspKeys());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.Clients.AddRange(CreateListEntities.Clients());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                getByNumberKey = clientL.GetByNumberKey(1);
            }

            Assert.AreEqual(getByNumberKey, actual);
        }