Ejemplo n.º 1
0
        public void SettingManager_With_TrackableObjects()
        {
            // arrange
            var settingsManager = new SettingsManager(SettingsTestsDirectory);
            var settings = new BuildServerSettings
            {
                User = new User { FirstName = "Alexander", LastName = "Beletsky" },
                Jobs = new List<Job> { new Job { Id = 0, Configuration = "Git", Name = "proj" } },
            };

            settingsManager.SaveSettings(settings);

            // act
            using (var trackableSettingsManager = new AutoSaveSettingsManager(settingsManager))
            {
                var restoredSettings = trackableSettingsManager.ReadSettings<BuildServerSettings>();
                restoredSettings.User.FirstName = "John";
                restoredSettings.User.LastName = "Doe";
            }

            // post
            var changedSettings = settingsManager.ReadSettings<BuildServerSettings>();
            Assert.That(changedSettings.User.FirstName, Is.EqualTo("John"));
            Assert.That(changedSettings.User.LastName, Is.EqualTo("Doe"));
        }
Ejemplo n.º 2
0
        public void Create(string login, string password)
        {
            using (var settings = new AutoSaveSettingsManager(_settingsManager))
            {
                var userSettings = settings.ReadSettings<UserSettings>();
                var user = new User
                               {
                                   Login = login,
                                   PasswordHash = _hashService.CreateMD5Hash(password)
                               };

                userSettings.CurrentUser = user;
            }
        }