public void TestLoadExistingFile()
        {
            // arrange
            var fileSystem = new MockFileSystem();
            var provider   = new AppSettingsProvider(fileSystem);

            provider.Save(new AppSettings().SetLatestPhotoFolder("hello world"));
            provider = new AppSettingsProvider(fileSystem);

            // act/assert
            Assert.Equal("hello world", provider.Current.LatestPhotoFolder);
        }
        public void TestSaveWhenNoFileExists()
        {
            // arrange
            var fileSystem = new MockFileSystem();
            var provider   = new AppSettingsProvider(fileSystem);

            // act
            provider.Save(new AppSettings().SetLatestPhotoFolder("Hello World"));

            // assert
            Assert.Equal("Hello World", provider.Current.LatestPhotoFolder);
            Assert.Single(fileSystem.AllFiles);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {

            
            var sqlServer =
                new SqlServerSettingsStore(
                    @"Server=WINSERVER-BUILD\TEST,8000;Database=StockBuddy;User Id=APP_StockBuddy;Password=5%{F*Uz5Tn$]`eG5J_P5$ZBU?;",
                    tableName: "MySettings",
                    settingsId:1);

            //var file = new FileSystemSettingsStore("settingsNew.txt");

            var appSettings = new AppSettingsProvider<MySettings>(sqlServer);

            appSettings.Instance.SystemName = "Test";
            appSettings.Save();

            appSettings.Reload();

            Console.WriteLine(appSettings.Instance.SystemName);
            Console.WriteLine(appSettings.Instance.Age);
            Console.WriteLine(appSettings.Instance.TaxRate);
            Console.WriteLine("");





            //appSettings.Instance.AppName = "Det er fint: " + DateTime.Now.ToString();
            //appSettings.Instance.KeyboardState = KeyboardStates.NotWorking;
            //appSettings.Instance.MaxNumberOfUsers = new Random().Next(1, 50);

            //appSettings.Save();

            //appSettings.Reload();










            Console.Read();
        }