Esempio n. 1
0
        public async void DeactivatePluginAsync_turns_plugin_active_to_false()
        {
            // Arrange a plugin meta
            var key      = "myplugin";
            var myPlugin = new MyPlugin {
                Active = true
            };
            var meta = new Meta {
                Id = 1, Key = key, Value = JsonConvert.SerializeObject(myPlugin), Type = EMetaType.Plugin
            };

            metaRepoMock.Setup(repo => repo.GetAsync(key, EMetaType.Plugin)).Returns(Task.FromResult(meta));
            metaRepoMock.Setup(repo => repo.GetAsync(1)).Returns(Task.FromResult(meta));

            // Act when user de-activates it
            await pluginService.DeactivatePluginAsync(1);

            // Assert the plugin is updated at datasource
            metaRepoMock.Verify(repo => repo.UpdateAsync(It.IsAny <Meta>()), Times.Once);
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostDeactivateAsync([FromBody] PluginDto dto)
        {
            await pluginService.DeactivatePluginAsync(dto.Id);

            return(new JsonResult(true));
        }