Exemplo n.º 1
0
        public void CanAddNewWareType()
        {
            var wareType = new WareType { Name = "N76",WareGroup = _child1_1 ,Producer = _producer2};

            _repository.Save(wareType);
            using (ISession session = sessions.OpenSession())
            {
                var fromDb = session.Get<WareType>(wareType.Id);

                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(wareType, fromDb);
                Assert.AreEqual(wareType.Name, fromDb.Name);
                Assert.AreEqual(wareType.WareGroup.Name,fromDb.WareGroup.Name);
                Assert.AreEqual(wareType.Producer.Caption,fromDb.Producer.Caption);
            }
        }
Exemplo n.º 2
0
        private void CreateInitialData()
        {
            _root = new WareGroup {Name = "Электронные товары"};
            _child1 = new WareGroup {Name = "Мобильные телефоны"};
            _child1_1 = new WareGroup {Name = "Раскладушки"};
            _child1_2 = new WareGroup {Name = "Моноблоки"};
            _child2 = new WareGroup {Name = "Процессоры"};
            _root.AddChild(_child1);
            _root.AddChild(_child2);
            _child1.AddChild(_child1_1);
            _child1.AddChild(_child1_2);
            _root2 = new WareGroup{Name = "Антиквариат"};
            _producer = new Producer {Caption = "Nokia"};
            _producer2 = new Producer {Caption = "Intel"};
            _model1 = new WareType {Name = "N78", WareGroup = _child1_2,Producer = _producer};
            _model2 = new WareType { Name = "T2100", WareGroup = _child2,Producer = _producer2};
            using (var session = sessions.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(_root);
                    session.Save(_child1);
                    session.Save(_child1_1);
                    session.Save(_child1);
                    session.Save(_child1_2);
                    session.Save(_child2);
                    session.Save(_root2);
                    transaction.Commit();
                }
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(_root2);
                    transaction.Commit();
                }
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(_producer);
                    session.Save(_producer2);
                    transaction.Commit();
                }
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(_model1);
                    transaction.Commit();

                }
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(_model2);
                    transaction.Commit();

                }
            }

            _repository = new Dao<WareType>(sessions);
            var repositorysession = sessions.OpenSession();
            CurrentSessionContext.Bind(repositorysession);
        }
Exemplo n.º 3
0
        private void CreateInitialData()
        {
            _wareGroup = new WareGroup {Name = "Мобильный телефон"};
            _producer = new Producer {Caption = "LG"};
            _wareType = new WareType {Name = "i234", Producer = _producer, WareGroup = _wareGroup};
            _wareType2 = new WareType {Name = "4324", Producer = _producer, WareGroup = _wareGroup};
            _client = new Client {FIO = "Розничный клиент",ContactPhone = "нет",Identification = "нет"};
            _client2 = new Client{FIO ="Барыга Леха",ContactPhone = "78-32-43",Identification = "Талон"};
            _worker = new Worker{FIO = "Саша"};
            _worker2 = new Worker {FIO = "Вова"};
            _ware = new Ware
                        {
                            WareType = _wareType,
                            ClientBrought = _client,
                            Description = "Потертый телефон",
                            Worker = _worker
                        };
            _ware2 = new Ware
                         {
                             ClientBrought = _client2,
                             Description = "Нет крышки",
                             WareType = _wareType2,
                             Worker = _worker2
                         };
            using (ISession session = sessions.OpenSession())
            using (ITransaction transaction = session.BeginTransaction())
            {

                session.Save(_wareGroup);
                session.Save(_producer);
                session.Save(_wareType);
                session.Save(_wareType2);
                session.Save(_client);
                session.Save(_client2);
                session.Save(_worker);
                session.Save(_producer);
                session.Save(_producer);
                session.Save(_worker2);
                session.Save(_ware);
                session.Save(_ware2);
                transaction.Commit();

            }
            _repository = new Dao<Ware>(sessions);
            var repositorysession = sessions.OpenSession();
            CurrentSessionContext.Bind(repositorysession);
        }