Exemplo n.º 1
0
        public async void ActivateThemeAsync_registers_any_theme_defined_widget_areas()
        {
            // Arrange
            // mytheme meta reocrd
            var key     = "mytheme";
            var myTheme = new MyTheme();
            var meta    = new Meta {
                Id = 1, Key = key, Value = JsonConvert.SerializeObject(myTheme), Type = EMetaType.Plugin
            };

            metaRepoMock.Setup(repo => repo.GetAsync(key, EMetaType.Theme)).Returns(Task.FromResult(meta));
            // theme defined widget areas not exist
            metaRepoMock.Setup(repo => repo.GetAsync(It.IsAny <string>(), EMetaType.WidgetAreaByTheme))
            .Returns(Task.FromResult((Meta)null));

            // Act activate a theme
            await themeService.ActivateThemeAsync(myTheme.Folder);

            // Assert a theme defined widget area is inserted
            var metaWidgetArea = new Meta
            {
                Key   = "mytheme-my-area",
                Value = "{\"Id\":\"my-area\",\"WidgetIds\":[]}",
                Type  = EMetaType.WidgetAreaByTheme
            };

            metaRepoMock.Verify(repo =>
                                repo.CreateAsync(It.Is <Meta>(m =>
                                                              m.Key == metaWidgetArea.Key &&
                                                              m.Value == metaWidgetArea.Value &&
                                                              m.Type == metaWidgetArea.Type)),
                                Times.Once);
        }
Exemplo n.º 2
0
        public async void ActivateThemeAsync_registers_theme_if_not_already_exist()
        {
            // Given
            // "mytheme" meta record not exist
            var myTheme = new MyTheme();

            metaRepoMock.Setup(repo => repo.GetAsync("mytheme", EMetaType.Theme)).Returns(Task.FromResult((Meta)null));

            // When
            await themeService.ActivateThemeAsync(myTheme.Folder);

            // Then
            // mytheme meta record is create
            var metaTheme = new Meta
            {
                Key   = "mytheme",
                Value = "",
                Type  = EMetaType.Theme
            };

            metaRepoMock.Verify(repo =>
                                repo.CreateAsync(It.Is <Meta>(m =>
                                                              m.Key == metaTheme.Key &&
                                                              m.Value == metaTheme.Value &&
                                                              m.Type == metaTheme.Type)),
                                Times.Once);
        }