コード例 #1
0
        public void ReturnAllTagListWidgets()
        {
            Int32 widgetCount = 20.GetRandom(6);

            string rootPath         = $"C:\\{string.Empty.GetRandom()}";
            var    connectionString = new ConnectionStringBuilder("this")
                                      .AddFilePath(rootPath)
                                      .Build();

            var widgets = new WidgetFileBuilder()
                          .AddTagListWidgets(widgetCount)
                          .Build();

            Int32 expected = widgets.Count(w => w.Active);

            var fileSystem = new MockFileServiceBuilder()
                             .AddWidgets(widgets)
                             .Build(rootPath);

            var target = new ContentRepositoryBuilder()
                         .AddFileService(fileSystem.Object)
                         .UseGenericDirectory()
                         .Build(connectionString);

            var actual = target.GetAllWidgets();

            Assert.Equal(expected, actual.Count());
        }
コード例 #2
0
        private static void ExecutePropertyTest(WidgetZone widget, String expected, Func <Widget, string> fieldValueDelegate)
        {
            string rootPath         = $"C:\\{string.Empty.GetRandom()}";
            var    connectionString = new ConnectionStringBuilder("this")
                                      .AddFilePath(rootPath)
                                      .Build();

            var fileSystem = new MockFileServiceBuilder()
                             .AddWidget(widget)
                             .Build(rootPath);

            var target = new ContentRepositoryBuilder()
                         .AddFileService(fileSystem.Object)
                         .UseGenericDirectory()
                         .Build(connectionString);

            var actualWidgets = target.GetAllWidgets();
            var actual        = actualWidgets.Single();

            Assert.Equal(expected, fieldValueDelegate(actual));
        }