示例#1
0
        public void ModuleSettingsPresenter_LoadSettings_Loads_Both_Dictionaries()
        {
            //Arrange
            var view = new Mock <ISettingsView <SettingsModel> >();

            view.SetupGet(v => v.Model).Returns(new SettingsModel());

            var presenter = new TestSettingsPresenter(view.Object)
            {
                ModuleContext = CreateModuleContext()
            };

            presenter.IsPostBack = false;

            view.Raise(v => v.Load += null, EventArgs.Empty);

            //Act
            view.Raise(v => v.OnLoadSettings += null, EventArgs.Empty);

            //Assert
            Assert.IsInstanceOf <Dictionary <string, string> >(view.Object.Model.ModuleSettings);
            Assert.AreEqual(_moduleSettingCount, view.Object.Model.ModuleSettings.Count);

            Assert.IsInstanceOf <Dictionary <string, string> >(view.Object.Model.TabModuleSettings);
            Assert.AreEqual(_tabModuleSettingCount, view.Object.Model.TabModuleSettings.Count);
        }
示例#2
0
        public void ModuleSettingsPresenter_SaveSettings_Saves_TabModuleSettings()
        {
            //Arrange
            var view = new Mock <ISettingsView <SettingsModel> >();

            view.SetupGet(v => v.Model).Returns(new SettingsModel());

            var controller = new Mock <IModuleController>();


            var presenter = new TestSettingsPresenter(view.Object)
            {
                ModuleContext = CreateModuleContext()
            };

            presenter.IsPostBack    = true;
            view.Raise(v => v.Load += null, EventArgs.Empty);

            //Act
            view.Raise(v => v.OnSaveSettings += null, EventArgs.Empty);

            //Assert
            foreach (var setting in view.Object.Model.TabModuleSettings)
            {
                var key   = setting.Key;
                var value = setting.Value;
                controller.Verify(c => c.UpdateTabModuleSetting(It.IsAny <int>(), key, value), Times.Once());
            }
        }
        public void ModuleSettingsPresenter_Load_Does_Not_Initialise_Dictionaries_If_Not_PostBack()
        {
            // Arrange
            var view = new Mock<ISettingsView<SettingsModel>>();
            view.SetupGet(v => v.Model).Returns(new SettingsModel());

            var presenter = new TestSettingsPresenter(view.Object) { ModuleContext = this.CreateModuleContext() };
            presenter.IsPostBack = false;

            // Act
            view.Raise(v => v.Load += null, EventArgs.Empty);

            // Assert
            Assert.IsNull(view.Object.Model.ModuleSettings);
            Assert.IsNull(view.Object.Model.TabModuleSettings);
        }