-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated BuildHistory to store a cache of build capabilities
Updated DefaultExecuteStrategy to manage cached build capabilities
- Loading branch information
1 parent
bedcfda
commit 1738a25
Showing
6 changed files
with
282 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace ModelBuilder.UnitTests | ||
{ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
public class BuildHistoryItemTests | ||
{ | ||
[Fact] | ||
public void CapabilitiesReturnsEmptyByDefault() | ||
{ | ||
var value = Guid.NewGuid().ToString(); | ||
|
||
var actual = new BuildHistoryItem(value); | ||
|
||
actual.Capabilities.Should().BeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void ThrowsExceptionWithNullInstance() | ||
{ | ||
// ReSharper disable once ObjectCreationAsStatement | ||
Action action = () => new BuildHistoryItem(null!); | ||
|
||
action.Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void ValueReturnsConstructorValue() | ||
{ | ||
var value = Guid.NewGuid().ToString(); | ||
|
||
var actual = new BuildHistoryItem(value); | ||
|
||
actual.Value.Should().Be(value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace ModelBuilder | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using ModelBuilder.BuildActions; | ||
|
||
/// <summary> | ||
/// The <see cref="BuildHistoryItem" /> | ||
/// class is used to track items built and related build capabilities. | ||
/// </summary> | ||
public class BuildHistoryItem | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BuildHistoryItem" /> class. | ||
/// </summary> | ||
/// <param name="value">The value created.</param> | ||
public BuildHistoryItem(object value) | ||
{ | ||
Value = value ?? throw new ArgumentNullException(nameof(value)); | ||
} | ||
|
||
/// <summary> | ||
/// The cache of build capabilities by requested types. | ||
/// </summary> | ||
public Dictionary<Type, IBuildCapability> Capabilities { get; } = new Dictionary<Type, IBuildCapability>(); | ||
|
||
/// <summary> | ||
/// Gets the value created. | ||
/// </summary> | ||
public object Value { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters