コード例 #1
0
        public void ImpossibleBuild()
        {
            // Arrange
            var builds = new Dictionary <string, BuildableObject>
            {
                { "1", new BuildableObject {
                      Id = "a", RequiredIds = new[] { "2" }
                  } },
                { "2", new BuildableObject {
                      Id = "b", RequiredIds = new[] { "2" }
                  } },
                { "3", new BuildableObject {
                      Id = "c", RequiredIds = new[] { "4" }
                  } },
                { "4", new BuildableObject {
                      Id = "d", RequiredIds = new string[0]
                  } },
                { "5", new BuildableObject {
                      Id = "e", RequiredIds = new[] { "4" }
                  } }
            };
            var builder = new SuspendBuildsManager <BuildableObject, string>(builds, BuildableObject.BuildMethod);

            // Act
            var resultStatus = builder.Build();
            var result       = builder.GetResult();

            // Assert
            Assert.False(resultStatus, "Build should be possible");
            Assert.Equal(3, result.Keys.Count);
        }
コード例 #2
0
        public void MultiDependentTaskBuild()
        {
            // Arrange
            var builds = new Dictionary <string, BuildableObject>
            {
                { "1", new BuildableObject {
                      Id = "a", RequiredIds = new[] { "2" }
                  } },
                { "2", new BuildableObject {
                      Id = "b", RequiredIds = new string[0]
                  } },
                { "3", new BuildableObject {
                      Id = "c", RequiredIds = new[] { "4" }
                  } },
                { "4", new BuildableObject {
                      Id = "d", RequiredIds = new string[0]
                  } },
                { "5", new BuildableObject {
                      Id = "e", RequiredIds = new[] { "4" }
                  } }
            };
            var builder = new SuspendBuildsManager <BuildableObject, string>(builds, BuildableObject.BuildMethod);

            // Act
            var resultStatus = builder.Build();
            var result       = builder.GetResult();

            // Assert
            Assert.True(resultStatus, "Build should be possible");
            Assert.Equal(builds.Keys.Count, result.Keys.Count);
            Assert.Equal(builds.Select(x => x.Value.Id).OrderBy(x => x),
                         result.Select(x => x.Value).OrderBy(x => x));
        }
コード例 #3
0
ファイル: Deserializer301.cs プロジェクト: lukmccall/CookBook
        private void MapSchemes(OpenApiModel.OpenApiModelBuilder openApiBuilder,
                                Dictionary <string, Schema> versionedSchemes)
        {
            var buildManager =
                new SuspendBuildsManager <Schema, ISchema>(versionedSchemes, BuilderInitializers.SchemaMap);

            if (!buildManager.Build())
            {
                throw new ArgumentException("Couldn't create schemes. Pleas validate them earlier.");
            }

            openApiBuilder.AttachScheme(buildManager.GetResult());
        }
コード例 #4
0
        public void SimpleBuild()
        {
            // Arrange
            var builds = new Dictionary <string, BuildableObject>
            {
                { "1", new BuildableObject {
                      Id = "1", RequiredIds = new string[0]
                  } }
            };
            var builder = new SuspendBuildsManager <BuildableObject, string>(builds, BuildableObject.BuildMethod);

            // Act
            var resultStatus = builder.Build();
            var result       = builder.GetResult();

            // Assert
            Assert.True(resultStatus, "Build should be possible");
            Assert.Single(result.Values);
            Assert.Equal("1", result["1"]);
        }