Skip to content

Commit

Permalink
Update BuilderUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Dec 6, 2023
1 parent 9e40bfc commit 7b673d0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
23 changes: 22 additions & 1 deletion Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ public void Build_ShouldBe_NotNull_Config()
Assert.IsTrue(builder.Config);
}

[TestCase("path")]
[TestCase("path2")]
[TestCase("path3")]
public void Build_ShouldBe_Config_Build(string path)
{
var builder = BuilderUtils.Build<Builder>((build) => { build.Config = true; });
builder.Build(path);
Assert.IsTrue(builder.Config);
Assert.AreEqual(builder.Path, path);
}

[TestCase("path")]
[TestCase("path2")]
[TestCase("path3")]
Expand All @@ -41,11 +52,21 @@ public void Build_ShouldBe_Path(string path)
[TestCase("path")]
[TestCase("path2")]
[TestCase("path3")]
public void Build_ShouldBe_Path_Config(string path)
public void Build_ShouldBe_Config_Path(string path)
{
var builder = BuilderUtils.Build<Builder>((build) => { build.Config = true; }, path);
Assert.IsTrue(builder.Config);
Assert.AreEqual(builder.Path, path);
}

[TestCase("path")]
[TestCase("path2")]
[TestCase("path3")]
public void Build_ShouldBe_Path_Config(string path)
{
var builder = BuilderUtils.Build<Builder>(path, (build) => { build.Config = true; });
Assert.IsTrue(builder.Config);
Assert.AreEqual(builder.Path, path);
}
}
}
13 changes: 13 additions & 0 deletions Autodesk.PackageBuilder/Utils/BuilderUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ public static TBuilder Build<TBuilder>(string path)
return builder;
}

/// <summary>
/// Create a new instance of the <typeparamref name="TBuilder"/> type, <paramref name="config"/> the instance, and <see cref="IBuilder.Build(string)"./>.
/// </summary>
/// <typeparam name="TBuilder"></typeparam>
/// <param name="path"></param>
/// <param name="config"></param>
/// <returns></returns>
public static TBuilder Build<TBuilder>(string path, Action<TBuilder> config)
where TBuilder : IBuilder, new()
{
return Build(config, path);
}

/// <summary>
/// Create a new instance of the <typeparamref name="TBuilder"/> type, <paramref name="config"/> the instance, and <see cref="IBuilder.Build(string)"./>.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.0.6] / 2023-11-24
## [1.0.6] / 2023-11-24 - 2023-12-06
### Features
- `Tests` project.
- Update `BuilderUtils` to return instance and features (#16).
### PackageBuilder
- Enable `DocumentationFile` in package.
- Update `BuilderUtils` to return instance.
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ BuilderUtils.Build<DemoPackageBuilder>("PackageContents.xml");

// or
BuilderUtils.Build<DemoPackageBuilder>("PackageContents.xml", builder => {...});

// or
BuilderUtils.Build<DemoPackageBuilder>(builder => {...}, "PackageContents.xml");

// or
BuilderUtils.Build<DemoPackageBuilder>(builder => {...}).Build("PackageContents.xml");
```

### Create RevitAddin.addin
Expand Down Expand Up @@ -197,7 +205,15 @@ BuilderUtils.Build<DemoAddinBuilder>("RevitAddin.addin");

// or
BuilderUtils.Build<DemoAddinBuilder>("RevitAddin.addin", builder => {...});

// or
BuilderUtils.Build<DemoAddinBuilder>(builder => {...}, "RevitAddin.addin");

// or
BuilderUtils.Build<DemoAddinBuilder>(builder => {...}).Build("RevitAddin.addin");
```

## Package Inspiration / Reference
Expand Down

0 comments on commit 7b673d0

Please sign in to comment.