Пример #1
0
        public void wont_accept_FileReader_as_input()
        {
            Action a = () => {
                FileReader m = new FileReader(@"data\FileSettingsReaderTestData");
                FileReader r = new FileReader(@"data\FileSettingsReaderTestData", m);
            };

            a.ShouldThrow<ArgumentException>();
        }
Пример #2
0
        public void filereader_reads_file()
        {
            var fileContent = System.IO.File.ReadAllText(@"data\FileSettingsReaderTestData");
            var settings = new Mock<ISettingsReader>();

            var filereader = new FileReader(@"data\FileSettingsReaderTestData", settings.Object);

            settings.VerifySet(m => { m.Settings = fileContent; }, Times.Once());
        }
Пример #3
0
        public void filereader_handles_an_non_existing_file_and_creates_it()
        {
            var filename = @"data\NotExisting";
            if (System.IO.File.Exists(filename))
                System.IO.File.Delete(filename);

            var settings = new Mock<ISettingsReader>();

            var filereader = new FileReader(filename, settings.Object);

            filereader.Save();
            System.IO.File.Exists(filename).Should().BeTrue();
        }
Пример #4
0
        public void filereader_is_transparent()
        {
            var settings = new Mock<ISettingsReader>();
            settings.SetupGet(m => m["hue"]).Verifiable();

            var filereader = new FileReader(@"data\FileSettingsReaderTestData", settings.Object);

            filereader.EnsureKey("hue", "9");
            var crap = filereader["hue"];
            var stuff = filereader.Keys;
            filereader.Settings = "new settings";
            crap = filereader.Settings;

            settings.Verify(m => m.EnsureKey("hue", "9"), Times.AtLeastOnce());

            settings.VerifyGet(m => m.Keys, Times.AtLeastOnce());
            settings.VerifyGet(m => m.Settings, Times.AtLeastOnce());
            settings.VerifySet(m => { m.Settings = "new settings"; }, Times.AtLeastOnce());
            settings.Verify();
        }
Пример #5
0
        public ShutupifyView()
        {
            InitializeComponent();
            InitializeComponentCustom();

            FileReader settingsReader = null;
            if (System.IO.File.Exists("shutupify.settings"))
                settingsReader = new FileReader("shutupify.settings");
            sirHookalot = new AutoHooker(settingsReader);

            sirHookalot.ReactOnEvent += (t) => {
                try {
                    lastFoo = DateTime.Now.ToLongTimeString() + "::" + t.ToString();
                    RefreshBox(null, null);
                }
                catch (Exception e) {
                    lastFoo = e.Message;
                };
            };
            sirHookalot.Hookup();

            if (settingsReader != null)
                settingsReader.Save();
        }