コード例 #1
0
        private SeedBucketInfo CreateSeedBucketInfo(TSeedBucketImplementation implementation)
        {
            Type?  type               = typeExtractor.ExtractFrom(implementation);
            string fullName           = fullNameExtractor.ExtractFrom(implementation);
            string friendlyName       = friendlyNameExtractor.ExtractFrom(implementation);
            string description        = descriptionExtractor.ExtractFrom(implementation);
            var    containedSeedables = seedablesExtractor.ExtractFrom(implementation);

            SetSeedBucketInfosForNonContainedSeedables();

            return(new SeedBucketInfo
                   (
                       implementation,
                       type,
                       fullName,
                       friendlyName,
                       description,
                       containedSeedables,
                       Array.Empty <Error>()
                   ));

            void SetSeedBucketInfosForNonContainedSeedables()
            {
                foreach (var nonContainedSeedable in SeedableInfo.GetRequiredSeedableInfosNotContainedIn(containedSeedables))
                {
                    nonContainedSeedable.SeedBucket = seedBucketOfSeedableExtractor.ExtractFrom((TSeedableImplementation)nonContainedSeedable.Implementation);
                }
            }
        }
コード例 #2
0
        public void ReturnsᅠexpectedᅠfullyᅠpopulatedᅠSeedBucketInfoᅠthatᅠrequiresᅠotherᅠseedᅠbuckets()
        {
            // The dependancy graph:
            // Base _      (has no SeedBucket)
            // |      \
            // Common  |   (has two SeedBuckets ;-))
            // |      \/
            // First  /    (has SeedBucket)
            // |     /
            // Second      (has SeedBucket)
            // |
            // SeedBucket  (has SeedBucket)

            var baseAssemblyReference = createAssemblyBuilder()
                                        .AddSeed("BaseSeed01")
                                        .AddSeed("BaseSeed02", requires: "BaseSeed01")
                                        .AddScenario("BaseScenario01", requires: "BaseSeed01")
                                        .AddScenario("BaseScenario02", requires: "BaseSeed02")
                                        .BuildPersistedAssembly()
                                        .GetMetadataReference();

            var commonAssemblyReference = createAssemblyBuilder()
                                          .AddReference(baseAssemblyReference)
                                          .AddSeedBucket("CommonSeedBucket01")
                                          .AddSeedBucket("CommonSeedBucket02")
                                          .AddSeed("CommonSeed01")
                                          .AddSeed("CommonSeed02", requires: "BaseSeed01")
                                          .AddScenario("CommonScenario01", requires: "CommonSeed01")
                                          .AddScenario("CommonScenario02", requires: "BaseSeed02")
                                          .BuildPersistedAssembly()
                                          .GetMetadataReference();

            var firstAssemblyReference = createAssemblyBuilder()
                                         .AddReferences(baseAssemblyReference, commonAssemblyReference)
                                         .AddSeedBucket("FirstSeedBucket")
                                         .AddSeed("FirstSeed01")
                                         .AddSeed("FirstSeed02", requires: "CommonSeed01")
                                         .AddScenario("FirstScenario01", requires: "FirstSeed01")
                                         .AddScenario("FirstScenario02", requires: "CommonSeed02")
                                         .BuildPersistedAssembly()
                                         .GetMetadataReference();

            var secondAssemblyReference = createAssemblyBuilder()
                                          .AddReferences(baseAssemblyReference, commonAssemblyReference, firstAssemblyReference)
                                          .AddSeedBucket("SecondSeedBucket")
                                          .AddSeed("SecondSeed01", requires: "FirstSeed01")
                                          .AddSeed("SecondSeed02", requires: "CommonSeed01")
                                          .AddScenario("SecondScenario01", requires: "FirstSeed01")
                                          .AddScenario("SecondScenario02", requires: "BaseSeed02")
                                          .BuildPersistedAssembly()
                                          .GetMetadataReference();

            const string seedBucketTypeName     = "TestSeedBucket";
            const string seedBucketFriendlyName = "Test seed bucket friendly name";
            const string seedBucketDescription  = "Test seed bucket description";

            var seedBucket = assemblyBuilder
                             .AddReferences(baseAssemblyReference, commonAssemblyReference, firstAssemblyReference, secondAssemblyReference)
                             .AddSeedBucket(seedBucketTypeName, seedBucketFriendlyName, seedBucketDescription)
                             .AddSeed("FirstSeed", requires: "SecondSeed01")
                             .AddSeed("SecondSeed", "Second seed friendly name", "Second seed description", true, false, false, null, "FirstSeed", "SecondSeed02")
                             .AddSeed("ThirdSeed", "Third seed friendly name", "Third seed description", true, false, false, null, "FirstSeed", "SecondSeed", "SecondScenario01")
                             .AddScenario("FirstScenario", requires: "FirstSeed")
                             .AddScenario("SecondScenario", "Second scenario friendly name", "Second scenario description", "FirstSeed", "SecondSeed", "SecondScenario02")
                             .AddScenario("ThirdScenario", null, null, "FirstSeed", "SecondSeed", "FirstScenario", "SecondScenario")
                             .AddSeed("FourthSeed", requires: "ThirdScenario")
                             .BuildAssembly()
                             .GetSeedBucket(seedBucketTypeName);
            var type = seedBucket.GetType();

            var metaInfo = seedBucket.GetMetaInfo();

            // TODO: Put these two repeating checks into our own Should Assertions and get rid of copy-paste:
            //       containedSeedables.Should().HaveSeedBucket(SeedBucket seedBucket);
            //       containedSeedables.Should().HaveSeedBucketWithName(string seedBucketName);
            //       containedSeedables.Should().NotHaveSeedBucket();
            metaInfo
            .ContainedSeedables
            .Select(seedable => seedable.SeedBucket)
            .Distinct()
            .Should()
            .HaveCount(1);

            metaInfo
            .ContainedSeedables
            .Select(seedable => seedable.SeedBucket)
            .First()
            .Should()
            .BeSameAs(metaInfo);

            var nonContainedSeedables = SeedableInfo.GetRequiredSeedableInfosNotContainedIn(metaInfo.ContainedSeedables);

            var nonContainedSeedablesFromBase = nonContainedSeedables.Where(seedable => seedable.FullName.StartsWith("Base"));

            nonContainedSeedablesFromBase
            .Select(seedable => seedable.SeedBucket)
            .Distinct()
            .Should()
            .HaveCount(1);

            nonContainedSeedablesFromBase
            .Select(seedable => seedable.SeedBucket)
            .First()
            .Should()
            .BeNull();

            var nonContainedSeedablesFromCommon = nonContainedSeedables.Where(seedable => seedable.FullName.StartsWith("Common"));

            nonContainedSeedablesFromCommon
            .Select(seedable => seedable.SeedBucket)
            .Distinct()
            .Should()
            .HaveCount(1);

            nonContainedSeedablesFromCommon
            .Select(seedable => seedable.SeedBucket)
            .First()
            .Should()
            .BeNull();

            var nonContainedSeedablesFromFirst = nonContainedSeedables.Where(seedable => seedable.FullName.StartsWith("First"));

            nonContainedSeedablesFromFirst
            .Select(seedable => seedable.SeedBucket)
            .Distinct()
            .Should()
            .HaveCount(1);

            nonContainedSeedablesFromFirst
            .Select(seedable => seedable.SeedBucket !.FullName)
            .First()
            .Should()
            .Be("FirstSeedBucket");

            var nonContainedSeedablesFromSecond = nonContainedSeedables.Where(seedable => seedable.FullName.StartsWith("Second"));

            nonContainedSeedablesFromSecond
            .Select(seedable => seedable.SeedBucket)
            .Distinct()
            .Should()
            .HaveCount(1);

            nonContainedSeedablesFromSecond
            .Select(seedable => seedable.SeedBucket !.FullName)
            .First()
            .Should()
            .Be("SecondSeedBucket");
        }
コード例 #3
0
 /// <inheritdoc/>
 public bool Accepts(SeedableInfo seedableInfo) => partsOfSeedableFullName.Any(part => seedableInfo.FullName.Contains(part, System.StringComparison.InvariantCultureIgnoreCase));
コード例 #4
0
 /// <inheritdoc/>
 public bool Accepts(SeedableInfo seedableInfo) => seedableFullNames.Any(fullName => seedableInfo.FullName == fullName);
コード例 #5
0
 /// <inheritdoc/>
 public bool Accepts(SeedableInfo seedableInfo) => true;