Flush() public method

Method for flushing the session.
public Flush ( ) : void
return void
        public void GetAccountsByCustomerSomeAccountsFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", LastName = "roux", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };
            Customer thirdParty2 = new Customer { Code = "topsecret", Email = "*****@*****.**", LastName = "roux2", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };

            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="12354"};
            Account account2 = new Account { Balance = 202, BalanceDate = DateTime.Now, Number = "dsf2", Iban="12435"};

            Role role = new Role{Id=1};
            thirdParty1.RelatedAccounts.Add(account1, role);
            thirdParty1.RelatedAccounts.Add(account2, role);

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);
                repository.Save(account2);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty1.Id);
                Assert.AreEqual(2, accounts.Count);
            }
        }
Example #2
0
        public HttpResponseMessage CadastrarAluno([FromBody] Aluno aluno)
        {
            _repositorioAluno = new Repository <Aluno>(CurrentSession());

            ValidarCamposObrigatorios(aluno);
            if (Errors == null || !HasError())
            {
                VerificaUnicidade(aluno);
            }
            if (Errors != null && HasError())
            {
                return(SendErrorResponse(HttpStatusCode.BadRequest));
            }
            if (aluno.Id <= 0 || aluno.Token == null)
            {
                aluno.Token = GeraToken(aluno);
            }
            aluno.Senha = Crypto.SHA1(aluno.Senha);

            try
            {
                _repositorioAluno.Save(aluno);
                _repositorioAluno.Flush();

                return(MultipleResponse(HttpStatusCode.OK, aluno));
            }
            catch (Exception e)
            {
                AddError("Não foi possível salvar.");
                return(SendErrorResponse(HttpStatusCode.BadRequest));
            }
        }
Example #3
0
            public void GetOperationsByAccount_SomeOperationsFound()
            {
                IOperationRepository operationRepository = new OperationRepository(NhibernateHelper.SessionFactory);
                Repository           repository          = new Repository(NhibernateHelper.SessionFactory);

                Customer thirdParty1 = new Customer {
                    Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Olivier", LastName = "Roux", Password = "******", PasswordSalt = "sss"
                };
                Account account1 = new Account {
                    Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban = "1242255"
                };
                Account account2 = new Account {
                    Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban = "1242255"
                };
                Operation operation1 = new Operation {
                    Account = account1, Amount = 200, Direction = Direction.Credit, Motif = "blabla", TransactionCode = "1245"
                };
                Operation operation2 = new Operation {
                    Account = account1, Amount = 654, Direction = Direction.Debit, Motif = "blibli", TransactionCode = "1245"
                };

                using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
                {
                    repository.Save(thirdParty1);
                    repository.Save(account1);
                    repository.Save(account2);
                    repository.Save(operation1);
                    repository.Save(operation2);
                    repository.Flush();
                    IList <Operation> operations = operationRepository.GetOperationsByAccount(account1.Id);
                    Assert.AreEqual(2, operations.Count);
                }
            }
        public void FindIndividualCustomersByName()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository          repository         = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer {
                Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss"
            };

            IList <Customer> customers1;
            IList <Customer> customers2;
            IList <Customer> customers3;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                //repository.Save(account1);
                repository.Flush();

                String[] names1 = { customer.FirstName };
                String[] names2 = { customer.LastName };
                String[] names3 = { customer.FirstName, customer.LastName };

                customers1 = customerRepository.FindCustomersByName(names1);
                customers2 = customerRepository.FindCustomersByName(names2);
                customers3 = customerRepository.FindCustomersByName(names3);

                Assert.IsNotNull(customers1);
                Assert.IsNotNull(customers2);
                Assert.IsNotNull(customers3);
            }
            Assert.AreEqual("*****@*****.**", customers1[0].Email);
            Assert.AreEqual("*****@*****.**", customers2[0].Email);
            Assert.AreEqual("*****@*****.**", customers3[0].Email);
        }
        public void FindIndividualCustomersByName()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss" };

            IList<Customer> customers1;
            IList<Customer> customers2;
            IList<Customer> customers3;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                //repository.Save(account1);
                repository.Flush();

                String[] names1 = { customer.FirstName };
                String[] names2 = { customer.LastName };
                String[] names3 = { customer.FirstName, customer.LastName };

                customers1 = customerRepository.FindCustomersByName(names1);
                customers2 = customerRepository.FindCustomersByName(names2);
                customers3 = customerRepository.FindCustomersByName(names3);

                Assert.IsNotNull(customers1);
                Assert.IsNotNull(customers2);
                Assert.IsNotNull(customers3);

            }
            Assert.AreEqual("*****@*****.**", customers1[0].Email);
            Assert.AreEqual("*****@*****.**", customers2[0].Email);
            Assert.AreEqual("*****@*****.**", customers3[0].Email);
        }
Example #6
0
        private Participacao ResponderSolicitacao(Participacao participacao, bool aprovar)
        {
            _repositorioParticipacao = new Repository <Participacao>(CurrentSession());
            Participacao part = null;

            if (participacao != null)
            {
                part = _repositorioParticipacao.FindById(participacao.Id);
            }
            if (part != null)
            {
                part.Participando = aprovar;
                try
                {
                    _repositorioParticipacao.Save(part);
                    _repositorioParticipacao.Flush();
                }
                catch
                {
                    AddError("Não foi possível salvar.");
                    return(null);
                }
            }
            return(part);
        }
        /// <summary>
        ///  Handle 'around' advice for testing services
        /// </summary>
        public object Invoke(IMethodInvocation invocation)
        {
            object returnValue = null;

            _repository = ServiceTestBase.GetRepository();

            DomainRegistry.Repository = _repository;
            DomainRegistry.Library    = null;

            try
            {
                returnValue = invocation.Proceed();

                _repository.Flush();
                _repository.Clear();
            }
            catch (Exception e)
            {
                returnValue = ServiceResult.Error(invocation.Method.ReturnType, e);
            }

            _visitedObjects.Clear();
            VerifyNoRealDomainObjects(returnValue);
            return(returnValue);
        }
Example #8
0
        private void DefaultMigration()
        {
            if (false == Leagues.Any(x => x.Name == "Bundesliga"))
            {
                Repository.Save(new League((int?)null, "Bundesliga", 18));
            }
            else
            {
            }

            if (false == Roles.Any(x => x.Name == "Physio"))
            {
                Repository.Save(new Role((int?)null, "Physio"));
            }
            else
            {
            }

            if (false == Roles.Any(x => x.Name == "Trainer"))
            {
                Repository.Save(new Role((int?)null, "Trainer"));
            }
            else
            {
            }

            if (false == Roles.Any(x => x.Name == "Spieler"))
            {
                Repository.Save(new Role((int?)null, "Spieler"));
            }
            else
            {
            }
            Repository.Flush();
        }
Example #9
0
        public void GetAccountByCustomerNoAccountFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository         repository        = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer {
                Code = "tjdsklfs", Email = "*****@*****.**", LastName = "Roux", FirstName = "Olivier", Password = "******", PasswordSalt = "sss"
            };
            Customer thirdParty2 = new Customer {
                Code = "topsecret", Email = "*****@*****.**", LastName = "Roux2", FirstName = "Olivier", Password = "******", PasswordSalt = "sss"
            };
            Account account1 = new Account {
                Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban = "12349340943"
            };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);

                repository.Flush();

                IList <Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }
        public void GetTaskForAdvisor_Found()
        {
            ITaskRepository taskRepository = new TaskRepository(NhibernateHelper.SessionFactory);
            Repository      repository     = new Repository(NhibernateHelper.SessionFactory);

            Advisor advisor = new Advisor {
                Id = 1, FirstName = "FirstName"
            };
            Task task = new Task {
                Id = 1, Advisor = advisor
            };
            Task task1 = new Task {
                Id = 2, Advisor = advisor
            };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(advisor);
                repository.Save(task);
                repository.Save(task1);

                repository.Flush();

                IList <Task> tasks = taskRepository.GetTasksForAdvisor(advisor.Id);
                Assert.AreEqual(2, tasks.Count);
                Assert.AreEqual(tasks[0].Advisor.FirstName, advisor.FirstName);
            }
        }
Example #11
0
        public void CarAd_mapping_standalonetable()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            IRepository     repo           = new Repository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                Province p = new Province {
                    Label = "Province Sud"
                };
                City c = new City {
                    Label = "Nouméa", Province = p, LabelUrlPart = "city"
                };
                p.AddCity(c);
                repo.Save(p);
                repo.Save(c);

                User u = new User
                {
                    Email    = "email",
                    Password = "******"
                };
                repo.Save(u);

                Category cat = new Category
                {
                    Label        = "label",
                    LabelUrlPart = "label"
                };
                repo.Save(cat);

                CarAd carAd = new CarAd()
                {
                    Title        = "title",
                    Body         = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer      = true,
                    CreatedBy    = u,
                    City         = c,
                    Category     = cat,
                    Kilometers   = 2000,
                    Year         = 2013
                };
                repo.Save(carAd);

                Ad ad = new Ad()
                {
                    Title        = "title",
                    Body         = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer      = true,
                    CreatedBy    = u,
                    City         = c,
                    Category     = cat
                };
                repo.Save(ad);
                repo.Flush();
            }
        }
Example #12
0
        public void GetAdType_CarAdExists_ReturnType()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository      repo           = new Repository(sessionFactory);
            AdRepository    adRepo         = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email    = "*****@*****.**",
                    Password = "******"
                };
                repo.Save <User>(u);

                City c = new City
                {
                    Label        = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label        = "Auto",
                    LabelUrlPart = "Auto",
                    Type         = AdTypeEnum.CarAd
                };

                CarAd a = new CarAd
                {
                    Title        = "honda civic type R",
                    Body         = "the best!!",
                    CreatedBy    = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category     = cat,
                    Kilometers   = 25000,
                    Year         = 1998
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save <Province>(p1);
                repo.Save <City>(c);
                repo.Save <Category>(cat);
                long id = repo.Save <CarAd, long>(a);

                repo.Flush();

                #endregion

                Assert.AreEqual(AdTypeEnum.CarAd, adRepo.GetAdType(id));
            }
        }
Example #13
0
        public void CanDeleteAd_AdExistsAndNotDeleted_ReturnTrue()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository      repo           = new Repository(sessionFactory);
            AdRepository    adRepo         = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email    = "*****@*****.**",
                    Password = "******"
                };
                repo.Save <User>(u);

                City c = new City
                {
                    Label        = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label        = "Informatique",
                    LabelUrlPart = "Informatique",
                    Type         = AdTypeEnum.Ad
                };

                Ad a = new Ad
                {
                    Title        = "video game",
                    Body         = "the best!!",
                    CreatedBy    = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category     = cat,
                    IsDeleted    = false
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save <Province>(p1);
                repo.Save <City>(c);
                repo.Save <Category>(cat);
                long id = repo.Save <Ad, long>(a);

                repo.Flush();

                #endregion

                Assert.IsTrue(adRepo.CanDeleteAd(id));
            }
        }
Example #14
0
        public void GetAdById_GetAd_ReturnAdObject()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository      repo           = new Repository(sessionFactory);
            AdRepository    adRepo         = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email    = "*****@*****.**",
                    Password = "******"
                };
                repo.Save <User>(u);

                City c = new City
                {
                    Label        = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label        = "Moto",
                    LabelUrlPart = "Moto"
                };

                Ad a = new Ad
                {
                    Title        = "ship",
                    Body         = "computer",
                    CreatedBy    = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category     = cat
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save <Province>(p1);
                repo.Save <City>(c);
                repo.Save <Category>(cat);
                long id = repo.Save <Ad, long>(a);

                repo.Flush();

                #endregion

                Assert.AreEqual(a, adRepo.GetAdById <Ad>(id));
            }
        }
Example #15
0
        public void CarAd_mapping_standalonetable()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            IRepository repo = new Repository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                Province p = new Province { Label = "Province Sud" };
                City c = new City { Label = "Nouméa", Province = p, LabelUrlPart = "city" };
                p.AddCity(c);
                repo.Save(p);
                repo.Save(c);

                User u = new User
                {
                    Email = "email",
                    Password = "******"
                };
                repo.Save(u);

                Category cat = new Category
                {
                    Label = "label",
                    LabelUrlPart = "label"
                };
                repo.Save(cat);

                CarAd carAd = new CarAd()
                {
                    Title = "title",
                    Body = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer = true,
                    CreatedBy = u,
                    City = c,
                    Category = cat,
                    Kilometers = 2000,
                    Year = 2013
                };
                repo.Save(carAd);

                Ad ad = new Ad()
                {
                    Title = "title",
                    Body = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer = true,
                    CreatedBy = u,
                    City = c,
                    Category = cat
                };
                repo.Save(ad);
                repo.Flush();

            }
        }
Example #16
0
        public void InsertChildMedia_Ok()
        {
            Library library = Repository.Load <Library>(_libraryId);
            Media   media   = library.Create(Media.InstantiateOrphanedMedia(MediaType.Dvd, "test", "test description"));

            Repository.Flush();
            Repository.Clear();

            library = Repository.Load <Library>(_libraryId);
            Assert.AreEqual(4, library.OwnedMedia.Count());
        }
Example #17
0
        public void DeleteChildMedia_Ok()
        {
            Library library = Repository.Load <Library>(_libraryId);
            Media   media   = Repository.Load <Media>(_mediaId);

            library.Delete(media);

            Repository.Flush();
            Repository.Clear();

            library = Repository.Load <Library>(_libraryId);
            Assert.AreEqual(2, library.OwnedMedia.Count());
        }
Example #18
0
        public void Insert_Load_Ok()
        {
            Library library = Library.InstantiateLibrary();

            Repository.Add(library);
            Assert.IsTrue(library.Id != 0);

            Repository.Flush();
            Repository.Clear();

            library = Repository.Load <Library>(library.Id);

            Assert.AreEqual(0, library.OwnedMedia.Count());
        }
Example #19
0
        public static void GenerateData()
        {
            IGenerationSessionFactory factory = GenerationFactory.ConfigureFactory();

            IGenerationSession session = factory.CreateSession();

            Role[] roles = CreateAndSaveRoles(Repository);
            IList <CustomerProfile> profiles = CreateAndSaveCustomerProfiles(Repository);

            CreateAndSaveAgencies(session, Repository);
            CreateAndSaveOAuthConsumers(Repository);
            CreateCustomersWithAccounts(session, Repository, roles);

            Repository.Flush();
        }
Example #20
0
        public HttpResponseMessage AtualizarAluno([FromBody] Aluno aluno)
        {
            VerificaToken();
            if (Errors != null && HasError())
            {
                return(SendErrorResponse(HttpStatusCode.Unauthorized));
            }

            _repositorioAluno = new Repository <Aluno>(CurrentSession());

            ValidarCamposObrigatorios(aluno);
            VerificaUnicidade(aluno);
            var temp = _repositorioAluno.FindById(aluno.Id);

            if (temp != null && temp.Matricula != aluno.Matricula)
            {
                AddError("A Matrícula não pode ser alterada.");
            }
            if (Errors != null && HasError())
            {
                return(SendErrorResponse(HttpStatusCode.BadRequest));
            }
            if (aluno.Id <= 0 || aluno.Token == null)
            {
                aluno.Token = GeraToken(aluno);
            }
            if (string.IsNullOrEmpty(aluno.Senha))
            {
                aluno.Senha = temp.Senha;
            }
            else
            {
                aluno.Senha = Crypto.SHA1(aluno.Senha);
            }
            try
            {
                CurrentSession().Evict(temp);
                _repositorioAluno.Save(aluno);
                _repositorioAluno.Flush();

                return(MultipleResponse(HttpStatusCode.OK, aluno));
            }
            catch (Exception e)
            {
                AddError("Não foi possível salvar.");
                return(SendErrorResponse(HttpStatusCode.BadRequest));
            }
        }
Example #21
0
        public HttpResponseMessage CriarGrupo([FromBody] GrupoEstudo grupo)
        {
            VerificaToken();
            if (Errors != null && HasError())
            {
                return(SendErrorResponse(HttpStatusCode.Unauthorized));
            }

            _repositorioGrupoEstudo = new Repository <GrupoEstudo>(CurrentSession());
            _repositorioDisciplina  = new Repository <Disciplina>(CurrentSession());
            _repositorioAluno       = new Repository <Aluno>(CurrentSession());

            ValidarCamposObrigatorios(grupo);
            if (Errors != null && HasError())
            {
                return(SendErrorResponse(HttpStatusCode.BadRequest));
            }
            grupo.Disciplina = _repositorioDisciplina.FindById(grupo.Disciplina.Id);
            var alunoLogado = _repositorioAluno.Queryable()
                              .FirstOrDefault(x => x.Token == Request.Headers.Authorization.ToString());

            grupo.Lider = alunoLogado;

            try
            {
                _repositorioGrupoEstudo.Save(grupo);
                _repositorioGrupoEstudo.Flush();
                var participacao = new Participacao
                {
                    Tipo         = TipoParticipacao.Lider,
                    Aluno        = grupo.Lider,
                    Grupo        = grupo,
                    Participando = true,
                    Version      = 0
                };
                _repositorioParticipacao = new Repository <Participacao>(CurrentSession());
                _repositorioParticipacao.Save(participacao);
                _repositorioParticipacao.Flush();
                grupo.Disciplina = null;
                grupo.Lider      = null;
                return(MultipleResponse(HttpStatusCode.OK, grupo));
            }
            catch (Exception e)
            {
                AddError(e.Message);
                return(SendErrorResponse(HttpStatusCode.BadRequest));
            }
        }
        public void Find_NoExpression()
        {
            IClientRepository clientRepository = new ClientRepository(NHibernateHelper.SessionFactory, _accountRepository);
            Repository repository = new Repository(NHibernateHelper.SessionFactory);

            Client client = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };

            using (ITransaction transaction = NHibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(client);
                repository.Flush();

                IList<Client> result = clientRepository.Find(null);
                Assert.AreEqual(1, result.Count);
            }
        }
Example #23
0
        override public void SetUp()
        {
            base.SetUp();

            Library library = Library.InstantiateLibrary();

            Media media1 = library.Create(Media.InstantiateOrphanedMedia(MediaType.Book, "Book", "A test book"));
            Media media2 = library.Create(Media.InstantiateOrphanedMedia(MediaType.Cd, "CD", "A test cd"));
            Media media3 = library.Create(Media.InstantiateOrphanedMedia(MediaType.Dvd, "DVD", "A test dvd"));

            Repository.Flush();
            Repository.Clear();
            DomainRegistry.Library = null;

            _libraryId = library.Id;
            _mediaId   = library.OwnedMedia.First().Id;
        }
Example #24
0
        override public void SetUp()
        {
            base.SetUp();

            Library library = Library.InstantiateLibrary();

            Repository.Add(library);

            library.Create(Media.InstantiateOrphanedMedia(MediaType.Book, "Book", "A test book"));
            library.Create(Media.InstantiateOrphanedMedia(MediaType.Cd, "CD", "A test cd"));
            library.Create(Media.InstantiateOrphanedMedia(MediaType.Dvd, "DVD", "A test dvd"));

            Repository.Flush();
            Repository.Clear();

            _libraryId = library.Id;
        }
Example #25
0
        public void GetUserByIdentity_Found_NotFound()
        {
            IUserRepository userRepository = new UserRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Id = 1, Identification = "Ident", Email = "Test", Password = "******", FirstName = "Name", LastName = "Last", Code = "Code", PasswordSalt = "sss" };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Flush();
                UserIdentity user = userRepository.GetUserByIdentity(customer.Identification);
                UserIdentity user2 = userRepository.GetUserByIdentity("test");
                Assert.AreEqual(user.Email, customer.Email);
                Assert.AreEqual(user2, null);
            }
        }
Example #26
0
            public override void Execute()
            {
                Repository.Save(new FakeEntity(Pleasure.Generator.TheSameString()));
                Repository.Save(new FakeEntity(Pleasure.Generator.String()));

                Repository.SaveOrUpdate(new FakeEntity(Pleasure.Generator.TheSameString()));
                Repository.SaveOrUpdate(new FakeEntity(Pleasure.Generator.String()));

                Repository.Delete <FakeEntity>(Pleasure.Generator.TheSameString());
                Repository.Delete <FakeEntity>(Pleasure.Generator.TheSameString());

                Repository.Flush();
                Repository.Flush();


                Repository.DeleteAll <FakeEntity>();
                Repository.DeleteByIds <FakeEntity>(new object[] { 1, 2, 3 });
            }
Example #27
0
        public void Insert_Load_Ok()
        {
            Library library = Repository.Load <Library>(_libraryId);

            Media media = library.Create(Media.InstantiateOrphanedMedia(MediaType.Dvd, "test", "test description"));

            Repository.Add(media);
            Assert.IsTrue(media.Id != 0);

            Repository.Flush();
            Repository.Clear();

            media = Repository.Load <Media>(media.Id);

            Assert.AreEqual(MediaType.Dvd, media.Type);
            Assert.AreEqual("test", media.Name);
            Assert.AreEqual("test description", media.Description);
        }
        public void GetIndividualCustomerByCode_NotFound()
        {
            ICustomerRepository thirdPartyRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository          repository           = new Repository(NhibernateHelper.SessionFactory);

            Customer individualThirdParty1 = new Customer {
                Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss"
            };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(individualThirdParty1);
                repository.Flush();

                Customer individualThirdPartyRetrieved = thirdPartyRepository.GetCustomerByCode("a");
                Assert.IsNull(individualThirdPartyRetrieved);
            }
        }
        public void GetAdvisorByIdentity_Found_NotFound()
        {
            IAdvisorRepository advisorRepository = new AdvisorRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Advisor advisor = new Advisor { Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Identification="Ident"};

            Advisor retrievedAdvisor;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(advisor);
                repository.Flush();
                retrievedAdvisor = advisorRepository.GetAdvisorByIdentity(advisor.Identification);
            }
            Assert.IsNotNull(retrievedAdvisor);
            Assert.AreEqual(advisor.Email,retrievedAdvisor.Email);
        }
Example #30
0
        public void CreateMedia_FailDuplicate()
        {
            Library library = Repository.Load <Library>(_libraryId);
            Media   first   = library.Create(Media.InstantiateOrphanedMedia(MediaType.Dvd, "test dvd", "test description"));

            Repository.Flush();

            Media media = Media.InstantiateOrphanedMedia(MediaType.Dvd, "test dvd", "test description 2");

            try
            {
                Media newMedia = library.Create(media);
                Assert.Fail("exception not thrown");
            }
            catch (DuplicationException e)
            {
                Assert.AreEqual(first.Id, e.DuplicateId);
            }
        }
Example #31
0
        public void GetUserByIdentity_Found_NotFound()
        {
            IUserRepository userRepository = new UserRepository(NhibernateHelper.SessionFactory);
            Repository      repository     = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer {
                Id = 1, Identification = "Ident", Email = "Test", Password = "******", FirstName = "Name", LastName = "Last", Code = "Code", PasswordSalt = "sss"
            };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Flush();
                UserIdentity user  = userRepository.GetUserByIdentity(customer.Identification);
                UserIdentity user2 = userRepository.GetUserByIdentity("test");
                Assert.AreEqual(user.Email, customer.Email);
                Assert.AreEqual(user2, null);
            }
        }
Example #32
0
        public HttpResponseMessage CancelarParticipacao([FromBody] Participacao participacao)
        {
            VerificaToken();

            if (Errors != null & HasError())
            {
                return(SendErrorResponse(HttpStatusCode.Unauthorized));
            }

            if (participacao != null)
            {
                _repositorioParticipacao = new Repository <Participacao>(CurrentSession());
                bool exists = _repositorioParticipacao.Queryable().Where(x => x.Id == participacao.Id).Count() > 0;
                if (exists)
                {
                    try
                    {
                        _repositorioParticipacao.Delete(participacao.Id);
                        _repositorioParticipacao.Flush();
                    }
                    catch
                    {
                        AddError("Não foi possível cancelar.");
                    }
                }
                else
                {
                    AddError("O pedido não existe mais.");
                }
            }
            else
            {
                AddError("Informe o pedido de participação.");
            }

            if (Errors != null & HasError())
            {
                return(SendErrorResponse(HttpStatusCode.Unauthorized));
            }

            return(MultipleResponse(HttpStatusCode.OK, null));
        }
Example #33
0
        public void LibraryRegistry_FailTooManyLibrary()
        {
            Library library = Library.InstantiateLibrary();

            Repository.Add(library);

            Repository.Flush();
            Repository.Clear();
            DomainRegistry.Library = null;

            try
            {
                library = DomainRegistry.Library;
                Assert.Fail("no exception thrown");
            }
            catch (Exception exception)
            {
                Assert.AreEqual("more than 1 library found in database", exception.Message);
            }
        }
Example #34
0
        override public void SetUp()
        {
            base.SetUp();

            AtlantaServices.ClearServices();
            AtlantaServices.AddAdvisedService <IMediaService>(new MediaService(), new AopAroundTestAdvice());

            Library library = Library.InstantiateLibrary();

            Repository.Add(library);

            library.Create(Media.InstantiateOrphanedMedia(MediaType.Book, "Book 1", "A test book"));
            library.Create(Media.InstantiateOrphanedMedia(MediaType.Cd, "CD", "A test cd"));
            library.Create(Media.InstantiateOrphanedMedia(MediaType.Book, "Book 2", "A test book"));

            Repository.Flush();
            Repository.Clear();

            _user = User.InstantiateUser("testServiceUser");
        }
        public void GetAdvisorByIdentity_Found_NotFound()
        {
            IAdvisorRepository advisorRepository = new AdvisorRepository(NhibernateHelper.SessionFactory);
            Repository         repository        = new Repository(NhibernateHelper.SessionFactory);

            Advisor advisor = new Advisor {
                Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Identification = "Ident"
            };

            Advisor retrievedAdvisor;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(advisor);
                repository.Flush();
                retrievedAdvisor = advisorRepository.GetAdvisorByIdentity(advisor.Identification);
            }
            Assert.IsNotNull(retrievedAdvisor);
            Assert.AreEqual(advisor.Email, retrievedAdvisor.Email);
        }
Example #36
0
        public HttpResponseMessage EsqueciSenha([FromBody] string email)
        {
            _repositorioAluno = new Repository <Aluno>(CurrentSession());
            Aluno aluno = null;

            if (email != null && email.Length > 0)
            {
                aluno = _repositorioAluno.Queryable().FirstOrDefault(x => x.Email.ToLower().Equals(email.ToLower()));
            }
            if (aluno != null)
            {
                aluno.Senha = Crypto.SHA1("senhapadrao123");
                aluno.Token = GeraToken(aluno);
                try
                {
                    _repositorioAluno.Save(aluno);
                    _repositorioAluno.Flush();
                }
                catch (Exception)
                {
                    AddError("Não foi possível resetar a senha do aluno.");
                    return(SendErrorResponse(HttpStatusCode.BadRequest));
                }
                MailMessage mail = new MailMessage("*****@*****.**", email);
                mail.Priority = MailPriority.High;
                SmtpClient client = new SmtpClient();
                client.Port                  = 587;
                client.EnableSsl             = true;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials           = new NetworkCredential("*****@*****.**", "1103Bianca");
                client.Host                  = "smtp.gmail.com";
                mail.Subject                 = "Esquecimento de Senha - ClickStudy";
                mail.Body = "Favor acessar o aplicativo com a senha: senhapadrao123";
                client.Send(mail);
                return(MultipleResponse(HttpStatusCode.OK, null));
            }

            AddError("Não existe cadastro para o email informado");
            return(SendErrorResponse(HttpStatusCode.BadRequest));
        }
        public void GetAccountByCustomerNoAccountFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", LastName = "Roux", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };
            Customer thirdParty2 = new Customer { Code = "topsecret", Email = "*****@*****.**", LastName = "Roux2", FirstName = "Olivier", Password = "******", PasswordSalt = "sss" };
            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="12349340943"};

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }
        public void GetCustomerByCode_Found_NotFound()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "someCode", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", Identification = "Ident", PasswordSalt = "sss" };

            Customer foundCustomer;
            Customer notFoundCustomer;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Flush();

                foundCustomer = customerRepository.GetCustomerByCode(customer.Code);
                notFoundCustomer = customerRepository.GetCustomerByCode("a");
            }
            Assert.IsNull(notFoundCustomer);
            Assert.IsNotNull(foundCustomer);
            Assert.AreEqual("*****@*****.**", foundCustomer.Email);
        }
Example #39
0
        public void GetTaskForAdvisor_Found()
        {
            ITaskRepository taskRepository = new TaskRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Advisor advisor = new Advisor { Id =1, FirstName="FirstName"};
            Task task = new Task { Id = 1, Advisor = advisor };
            Task task1 = new Task { Id = 2, Advisor = advisor };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(advisor);
                repository.Save(task);
                repository.Save(task1);

                repository.Flush();

                IList<Task> tasks = taskRepository.GetTasksForAdvisor(advisor.Id);
                Assert.AreEqual(2, tasks.Count);
                Assert.AreEqual(tasks[0].Advisor.FirstName, advisor.FirstName);
            }
        }
        public void GetAccountsByClient_NoAccountFound()
        {
            IOperationRepository operationRepository = new OperationRepository(NHibernateHelper.SessionFactory);
            IAccountRepository accountRepository = new AccountRepository(NHibernateHelper.SessionFactory, operationRepository);
            Repository repository = new Repository(NHibernateHelper.SessionFactory);

            Client client1 = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };
            Client client2 = new Client { LastName = "Ccc", FirstName = "Ddd", StartDate = DateTime.Now };
            Account account1 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };
            Account account2 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };

            using (ITransaction transaction = NHibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(client1);
                repository.Save(client2);
                repository.Save(account1);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByClient(client2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }
Example #41
0
        /// <summary>
        ///  Handle 'around' advice for testing services
        /// </summary>
        public object Invoke(IMethodInvocation invocation)
        {
            object returnValue = null;
            _repository = ServiceTestBase.GetRepository();

            DomainRegistry.Repository = _repository;
            DomainRegistry.Library = null;

            try
            {
                returnValue = invocation.Proceed();

                _repository.Flush();
                _repository.Clear();
            }
            catch (Exception e)
            {
                returnValue = ServiceResult.Error(invocation.Method.ReturnType, e);
            }

            _visitedObjects.Clear();
            VerifyNoRealDomainObjects(returnValue);
            return returnValue;
        }
        public void AdvancedSearchAds_RealEstateAds_RealEstateProperties_ReturnRealEstateAd()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Location",
                    LabelUrlPart = "Location"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "appart",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                RealEstateType t1 = new RealEstateType
                {
                    Label = "Location"
                };

                District d = new District
                {
                    City = c,
                    Label = "Cheznous"
                };

                RealEstateAd loc = new RealEstateAd
                {
                    Id = 1,
                    Title = "appart",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Type = t1,
                    District = d,
                    RoomsNumber = 5,
                    IsFurnished = true,
                    SurfaceArea = 45
                };

                repo.Save(t1);
                repo.Save(d);
                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(loc);
                repo.Save(a);

                MotoBrand brand = new MotoBrand
                {
                    Label = "Suzuki"
                };

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "appart2",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                RealEstateAd loc2 = new RealEstateAd
                {
                    Id = 2,
                    Title = "appart2",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Type = t1,
                    District = d,
                    RoomsNumber = 4,
                    IsFurnished = true,
                    SurfaceArea = 65
                };
                repo.Save(loc2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    AndSearchStrings = new String[] { "appart" },
                    MinNbRooms = 2,
                    MaxNbRooms = 4,
                    DistrictId = 1,
                    RealEstateTypeId = 1,
                    IsFurnished = true,
                    MinSurfaceArea = 60,
                    MaxSurfaceArea = 65
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<RealEstateAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a2, result[0]);
            }
        }
        public void AdvancedSearchAds_MotorBoatEngineAd_MotorBoatEngineProperties_ReturnMotorBoatEngineAd()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Bateau à moteur",
                    LabelUrlPart = "Bateau"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "bateau",
                    Body = "la desc du bateau",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                MotorBoatEngineType mt = new MotorBoatEngineType()
                {
                    Id = 7,
                    Label = "4 temps"
                };

                MotorBoatEngineAd bat = new MotorBoatEngineAd
                {
                    Id = 1,
                    Title = "moteur",
                    Body = "la desc du bateau",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Price = 1000,
                    Hp = 100,
                    Year = 2005,
                    MotorType = mt
                };

                repo.Save(mt);
                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(bat);
                repo.Save(a);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    MotorEngineTypeId = 1,
                    MinHp = 99,
                    MaxHp = 100,
                    MinYear = 2004,
                    MaxYear = 2006
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<MotorBoatEngineAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a, result[0]);
            }
        }
        public void AdvancedSearchAds_MotoAds_MotoProperties_ReturnMotoAd()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                CarAd car = new CarAd
                {
                    Id = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u
                };

                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(car);
                repo.Save(a);

                Category cat2 = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                MotoBrand brand = new MotoBrand
                {
                    Label = "Suzuki"
                };

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat2
                };

                MotoAd moto = new MotoAd
                {
                    Id = 2,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat2,
                    Brand = brand,
                    EngineSize = 650,
                    CreatedBy = u
                };
                repo.Save(brand);
                repo.Save(cat2);
                repo.Save(moto);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    AndSearchStrings = new String[] { "aveo" },
                    BrandId = brand.Id,
                    MinEngineSize = 250,
                    MaxEngineSize = 800
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<MotoAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a2, result[0]);
            }
        }
        public void AdvancedSearchAds_Ad_MinMaxPrice_ReturnMatchingAds()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Location",
                    LabelUrlPart = "Location"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                Ad loc = new Ad
                {
                    Id = 1,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Price = 1000
                };

                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(loc);
                repo.Save(a);

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                Ad loc2 = new Ad
                {
                    Id = 2,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Price = 2000
                };
                repo.Save(loc2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    MinPrice = 0,
                    MaxPrice = 1000
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<Ad>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a, result[0]);
            }
        }
        public void AdvancedSearchAds_CarAds_CarProperties_ReturnCarAd()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto"
                };

                CarFuel fuel = new CarFuel
                {
                    Label = "Diesel"
                };

                VehicleBrand brand = new VehicleBrand
                {
                    Label = "Aveo"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                CarAd car = new CarAd
                {
                    Id = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    Year = 2011,
                    Kilometers = 10000,
                    IsAutomatic = true,
                    Fuel = fuel,
                    Brand = brand,
                    CreatedBy = u
                };

                repo.Save(brand);
                repo.Save(fuel);
                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(car);
                repo.Save(a);

                SearchAdCache a2 = new SearchAdCache
                {
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                CarAd car2 = new CarAd
                {
                    Id = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    Year = 2001,
                    Kilometers = 95000,
                    Brand = brand,
                    CreatedBy = u
                };
                repo.Save(car2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    AndSearchStrings = new String[] { "aveo" },
                    MinKm = 0,
                    MaxKm = 11000,
                    MinYear = 2000,
                    MaxYear = 2012,
                    BrandId = brand.Id,
                    FueldId = fuel.Id,
                    IsAuto = true
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<CarAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a, result[0]);
            }
        }
        public void SearchAds_SearchByTitleAndCategories()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "CherzmOi",
                    LabelUrlPart = "city"
                };

                Category cat = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "titre 1",
                    Body = "content",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                repo.Save(a);

                City c2 = new City
                {
                    Label = "CherzmOi2",
                    LabelUrlPart = "city2"
                };

                Category cat2 = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto"
                };

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "title 2",
                    Body = "content",
                    City = c2,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 17),
                    Category = cat2
                };
                repo.Save<City>(c2);
                repo.Save<Category>(cat2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                // When
                IList<SearchAdCache> result = adRepo.SearchAds(andSearchStrings: new String[] { "ti" }, categoryIds: new int[] { cat.Id, cat2.Id });

                // Then
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual(a, result[0]);
                Assert.AreEqual(a2, result[1]);
            }
        }
        public void GetIndividualCustomerByCode_Found()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss" };
            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="1234"};

            Customer retrievedCustomer;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Save(account1);
                repository.Flush();

                retrievedCustomer = customerRepository.GetCustomerByCode(customer.Code);
                Assert.IsNotNull(retrievedCustomer);
            }
        }
Example #49
0
        public void GetAdsByEmail_ReturnListOfAds_WithUserAndCategoryFetched()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            AdRepository adRepo = new AdRepository(sessionFactory);
            Repository repo = new Repository(sessionFactory);
            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                User u2 = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u2);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city",
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Informatique",
                    LabelUrlPart = "Informatique",
                    Type = AdTypeEnum.Ad
                };

                Category cat2 = new Category
                {
                    Label = "Voiture",
                    LabelUrlPart = "Voiture",
                    Type = AdTypeEnum.Ad
                };

                Ad a = new Ad
                {
                    Title = "video game",
                    Body = "the best!!",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    IsDeleted = false,
                    IsActivated = true
                };

                Ad a2 = new Ad
                {
                    Title = "Ferrari F430",
                    Body = "Valab'",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat2,
                    IsDeleted = false,
                    IsActivated = true
                };

                Ad a3 = new Ad
                {
                    Title = "Ferrari F430",
                    Body = "Valab'",
                    CreatedBy = u2,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat2,
                    IsDeleted = false,
                    IsActivated = true
                };
                c.AddAd(a);
                c.AddAd(a2);
                c.AddAd(a3);
                cat.AddAd(a);
                cat2.AddAd(a2);
                cat2.AddAd(a3);
                repo.Save<Province>(p1);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                repo.Save<Category>(cat2);
                repo.Save<Ad, long>(a);
                repo.Save<Ad, long>(a2);
                repo.Save<Ad, long>(a3);
                repo.Flush();
                #endregion

                List<BaseAd> adsUser1 = adRepo.GetAdsByEmail(u.Email).ToList();
                List<BaseAd> adsUser2 = adRepo.GetAdsByEmail(u2.Email).ToList();
                Assert.AreEqual(2, adsUser1.Count);
                Assert.AreEqual(u.Email, adsUser1[0].CreatedBy.Email);
                Assert.AreEqual(1, adsUser2.Count);
                Assert.AreEqual(u2.Email, adsUser2[0].CreatedBy.Email);
            }
        }
Example #50
0
        public void CountAdsByCity_2Citiesand3Ad_Return2elements()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "CherzmOi",
                    LabelUrlPart = "city"
                };

                Category cat = new Category
                {
                    Label = "Bateau",
                    LabelUrlPart = "Bateau"
                };

                Ad a = new Ad
                {
                    Title = "titre",
                    Body = "content",
                    CreatedBy = u,
                    City = c,
                    Category = cat
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                repo.Save<Ad>(a);

                Ad a2 = new Ad
                {
                    Title = "titre",
                    Body = "content",
                    CreatedBy = u,
                    City = c,
                    Category = cat
                };
                c.AddAd(a2);
                repo.Save<Ad>(a2);

                City c2 = new City
                {
                    Label = "CherzmOi 2",
                    LabelUrlPart = "city2",
                };
                Ad a3 = new Ad
                {
                    Title = "titre",
                    Body = "content",
                    CreatedBy = u,
                    City = c2,
                    Category = cat
                };
                c2.AddAd(a3);
                repo.Save<City>(c2);
                repo.Save<Ad>(a3);

                repo.Flush();

                #endregion

                // When
                IDictionary<City, int> result = adRepo.CountAdsByCity();

                // Then
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual(2, result[c]);
                Assert.AreEqual(1, result[c2]);
            }
        }
Example #51
0
        public void CanDeleteAd_AdExistsAndNotDeleted_ReturnTrue()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Informatique",
                    LabelUrlPart = "Informatique",
                    Type = AdTypeEnum.Ad
                };

                Ad a = new Ad
                {
                    Title = "video game",
                    Body = "the best!!",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    IsDeleted = false
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save<Province>(p1);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                long id = repo.Save<Ad, long>(a);

                repo.Flush();

                #endregion

                Assert.IsTrue(adRepo.CanDeleteAd(id));
            }
        }
Example #52
0
        public void GetAdType_CarAdExists_ReturnType()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto",
                    Type = AdTypeEnum.CarAd
                };

                CarAd a = new CarAd
                {
                    Title = "honda civic type R",
                    Body = "the best!!",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    Kilometers = 25000,
                    Year = 1998
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save<Province>(p1);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                long id = repo.Save<CarAd, long>(a);

                repo.Flush();

                #endregion

                Assert.AreEqual(AdTypeEnum.CarAd, adRepo.GetAdType(id));
            }
        }
        public void GetIndividualCustomerByCode_NotFound()
        {
            ICustomerRepository thirdPartyRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer individualThirdParty1 = new Customer { Code = "tjdsklfs", Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Password = "******", PasswordSalt = "sss" };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(individualThirdParty1);
                repository.Flush();

                Customer individualThirdPartyRetrieved = thirdPartyRepository.GetCustomerByCode("a");
                Assert.IsNull(individualThirdPartyRetrieved);
            }
        }
        public void AdvancedSearchAds_WaterSportAd_WaterSportProperties_ReturnWaterSportAd()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Bateau à moteur",
                    LabelUrlPart = "Bateau"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "bateau",
                    Body = "la desc du bateau",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                WaterSportType st = new WaterSportType()
                {
                    Label = "pmt"
                };

                WaterSportAd bat = new WaterSportAd
                {
                    Id = 1,
                    Title = "bateau",
                    Body = "la desc du bateau",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Type = st
                };

                repo.Save(st);
                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(bat);
                repo.Save(a);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    WaterTypeId = 1
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<WaterSportAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a, result[0]);
            }
        }
        public void SearchAds_SearchByTitleAndBodyAndString_CreateWhereAndQuery()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "ship",
                    Body = "computer",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };
                repo.Save<Province>(p1);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                repo.Save(a);

                Province p2 = new Province
                {
                    Label = "p2"
                };
                City c2 = new City
                {
                    Label = "CherzmOi2",
                    LabelUrlPart = "city2"
                };
                p2.AddCity(c2);
                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "ship",
                    Body = "content",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 17),
                    Category = cat
                };
                repo.Save<Province>(p2);
                repo.Save<City>(c2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                // When
                IList<SearchAdCache> result = adRepo.SearchAds(new String[] { "computer", "ship" }, null, null);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a, result[0]);
            }
        }
Example #56
0
        public void GetAdById_GetAd_ReturnAdObject()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                Ad a = new Ad
                {
                    Title = "ship",
                    Body = "computer",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save<Province>(p1);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                long id = repo.Save<Ad, long>(a);

                repo.Flush();

                #endregion

                Assert.AreEqual(a, adRepo.GetAdById<Ad>(id));
            }
        }
Example #57
0
        public void SearchAdsByTitle_SearchStringIsNull_ReturnEverythingOrderedByCreationDate()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "CherzmOi",
                    LabelUrlPart = "city"
                };

                Category cat = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                Ad a = new Ad
                {
                    Title = "titre 1",
                    Body = "content",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 12)
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                repo.Save<Ad>(a);

                Ad a2 = new Ad
                {
                    Title = "title 2",
                    Body = "content",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18)
                };
                c.AddAd(a2);
                cat.AddAd(a2);
                repo.Save<Ad>(a2);

                repo.Flush();

                #endregion

                // When
                IList<Ad> result = adRepo.SearchAdsByTitle(null);

                // Then
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual(a2, result[0]);
                Assert.AreEqual(a, result[1]);
            }
        }
        public void CountByCategory_NoSearchString_Returnwholecount()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository searchRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Voilier",
                    LabelUrlPart = "Bateau"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "bateau 1",
                    Body = "la desc du bateau",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                Category cat2 = new Category
                {
                    Label = "Bateau à moteur",
                    LabelUrlPart = "Bateau"
                };

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "poupou",
                    Body = "la desc du bateau",
                    City = c,
                    CreationDate = new DateTime(2012, 06, 11, 23, 52, 18),
                    Category = cat2
                };

                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(a);
                repo.Save(cat2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                // When
                IDictionary<Category, int> result = searchRepo.CountByCategory(new String[] { "bateau" }, null);

                // Then
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual(cat2, result.First().Key);
                Assert.AreEqual(cat, result.Last().Key);
            }
        }
Example #59
0
        public static void ComputeData(Stopwatch sw)
        {
            sw.Restart();
            var sessFactFactory = new SessionFactoryFactory(false);
            var sessionFactory = sessFactFactory.GetSessionFactory();
            var repository = new Repository(sessionFactory);
            repository.Clear();

            AggregationServices services = new AggregationServices(repository);

            services.ReAggregateAllOperations();
            sw.Stop();
            Console.WriteLine("Profiles computed in: {0}", sw.ElapsedMilliseconds);
            sw.Restart();
            services.ComputeBalancesForAllAccounts();

            repository.Flush();
            sw.Stop();
            Console.WriteLine("Balances computed in: {0}", sw.ElapsedMilliseconds);
        }