Пример #1
0
        public void Assure_only_given_userDB_is_replaced_with_saved_DB()
        {
            DeleteDatabaseIfExists();
            RecreateSessionFactory();
            repository = new UserdbDatabaseRepository(sessionFactory);
            var firstDB = new Userdb("default");
            firstDB.AddUser(new User("haldis"));

            var secondDB = new Userdb("not_default");
            secondDB.AddUser(new User("kari"));

            repository.Save(firstDB);
            repository.Save(secondDB);

            var firstDBUpdate = new Userdb("default");
            firstDBUpdate.AddUser(new User("tuxbear"));

            repository.Save(firstDBUpdate);

            var result = repository.Get(new AllSpecification<Userdb>());
            result.Count().ShouldBe(2);
            result.ElementAt(0).Name.ShouldBe("default");
            result.ElementAt(0).Users.First().Username.ShouldBe("tuxbear");
            result.ElementAt(1).Name.ShouldBe("not_default");
            result.ElementAt(1).Users.First().Username.ShouldBe("kari");

        }
Пример #2
0
        private void SaveCurrentUserdb()
        {
            var userdb = new Userdb(viewModel.CurrentDBName);

            foreach (var userViewModel in viewModel.Users)
            {
                userdb.AddUser(CreateUserDomainModelFromUserViewModel(userViewModel));
            }

            userdbPersisterRepository.Save(userdb);
        }
Пример #3
0
        private static bool UsersInUserdbOnlyHaveUsername(Userdb currentDb)
        {
            var usersOnlyHaveUsername = true;

            foreach (var user in currentDb.Users)
            {
                if (user.Firstname != null && !user.Firstname.Equals(""))
                {
                    usersOnlyHaveUsername = false;
                }
                if (user.Surname != null && !user.Surname.Equals(""))
                {
                    usersOnlyHaveUsername = false;
                }
            }
            return usersOnlyHaveUsername;
        }
Пример #4
0
 public User()
 {
     Database = new Userdb("default");
 }
Пример #5
0
 private void CreateDefaultUserdb()
 {
     var newUserDb = new Userdb(DEFAULT_USERDB_NAME);
     SetIsSavingData();
     userdbPersisterRepository.Save(newUserDb);
 }
Пример #6
0
        public void Assure_data_is_persisted()
        {
            Scenario.StartNew(this, scenario =>
            {
                scenario.Given(Database_is_created).
                    And(WebServiceClient_is_created);

                scenario.When("save", () =>
                {
                    var userdb = new Userdb("default");

                    userdb.AddUser(new User("ghansen")
                    {
                        Email = "*****@*****.**",
                        Firstname = "Gøran",
                        Surname = "Hansen",
                        ImageUrl = "http://goeran.no/avatar.jpg"
                    });
                    userRepositoryServiceClient.Save(new [] {userdb});
                });

                scenario.Then("assure data is persisted", () =>
                {
                    var user = databaseSession.CreateCriteria(typeof(User)).List<User>().
                        Where(u => u.Username == "ghansen").SingleOrDefault();
                    user.ShouldNotBeNull();
                    user.Database.ShouldNotBeNull();
                });
            });
        }
Пример #7
0
 public void Assure_Users_is_not_null()
 {
     var userdb = new Userdb();
     userdb.Users.ShouldNotBeNull();
 }