Esempio n. 1
0
        public void ReturnTheProperNameForEachCategory()
        {
            string rootPath         = $"C:\\{string.Empty.GetRandom()}";
            var    connectionString = new ConnectionStringBuilder("this")
                                      .AddFilePath(rootPath)
                                      .Build();

            var categories = new CategoryCollectionBuilder()
                             .AddRandomCategories(20.GetRandom(5))
                             .Build();

            var fileSystem = new MockFileServiceBuilder()
                             .AddCategories(categories)
                             .Build(rootPath);

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

            var actual = target.GetCategories();

            foreach (var category in categories)
            {
                var actualCategory = actual.SingleOrDefault(c => c.Id == category.Id);
                Assert.Equal(category.Name, actualCategory.Name);
            }
        }
Esempio n. 2
0
        public void ReturnAllCategories()
        {
            Int32 categoryCount = 20.GetRandom(5);

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

            var fileSystem = new MockFileServiceBuilder()
                             .AddRandomCategories(categoryCount)
                             .Build(rootPath);

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

            var actual = target.GetCategories();

            Assert.Equal(categoryCount, actual.Count());
        }