Пример #1
0
        public void HandlesNonExistentSettingsFile()
        {
            IMediator stubMediator = MockRepository.GenerateStub<IMediator>();
            SettingsPersister saver = new SettingsPersister(stubMediator, new CommandConsole(stubMediator, new Log<string>()));
            stubMediator.Stub(me => me.AvailableProperties).Return(new List<string>() { "Setting1" });
            stubMediator.Stub(me => me.Process("Setting1")).Return("5");

            string path = Path.Combine(StorageContainer.TitleLocation, SettingsPersister.SettingsFileName);
            File.Delete(path);

            saver.LoadSettings();

            stubMediator.AssertWasNotCalled(me => me.Process(Arg<string>.Is.Anything, Arg<string>.Is.Anything));
        }
Пример #2
0
        public void CanSaveAndReloadSettings()
        {
            IMediator stubMediator = MockRepository.GenerateStub<IMediator>();
            SettingsPersister saver = new SettingsPersister(stubMediator, new CommandConsole(stubMediator, new Log<string>()));
            stubMediator.Stub(me => me.AvailableProperties).Return(new List<string>() { "Setting1", "Setting2" });
            stubMediator.Stub(me => me.Process("Setting1")).Return("5");
            stubMediator.Stub(me => me.Process("Setting2")).Return("100 200");

            saver.SaveSettings();
            saver.LoadSettings();

            stubMediator.AssertWasCalled(me => me.Process("Setting1", "5"));
            stubMediator.AssertWasCalled(me => me.Process("Setting2", "100", "200"));
        }