Skip to content

Commit

Permalink
Merge pull request #28 from bsandmann/dev
Browse files Browse the repository at this point in the history
email action UI and classes
  • Loading branch information
ndigirigijohn authored Feb 17, 2025
2 parents 95b4c44 + 1a9e974 commit 4a6e68d
Show file tree
Hide file tree
Showing 15 changed files with 886 additions and 456 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using FluentAssertions;
using Xunit;

namespace Blocktrust.CredentialWorkflow.Core.Tests.Workflow.ExecuteWorkflow
{
public class ExecuteWorkflowHandlerTests
{
private readonly ExecuteWorkflowHandler _handler;

public ExecuteWorkflowHandlerTests()
{
// Since we're only testing ProcessEmailTemplate which doesn't use _mediator,
// we can pass null as it won't be used in our tests
_handler = new ExecuteWorkflowHandler(null!);
}

[Fact]
public void ProcessEmailTemplate_WithNullTemplate_ShouldReturnEmptyString()
{
// Arrange
string? template = null;
var parameters = new Dictionary<string, string>
{
{ "name", "John" }
};

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().BeEmpty();
}

[Fact]
public void ProcessEmailTemplate_WithEmptyTemplate_ShouldReturnEmptyString()
{
// Arrange
var template = string.Empty;
var parameters = new Dictionary<string, string>
{
{ "name", "John" }
};

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().BeEmpty();
}

[Fact]
public void ProcessEmailTemplate_WithNullParameters_ShouldReturnOriginalTemplate()
{
// Arrange
var template = "Hello [name], welcome!";
Dictionary<string, string>? parameters = null;

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().Be(template);
}

[Fact]
public void ProcessEmailTemplate_WithEmptyParameters_ShouldReturnOriginalTemplate()
{
// Arrange
var template = "Hello [name], welcome!";
var parameters = new Dictionary<string, string>();

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().Be(template);
}

[Fact]
public void ProcessEmailTemplate_WithSingleParameter_ShouldReplaceCorrectly()
{
// Arrange
var template = "Hello [name], welcome!";
var parameters = new Dictionary<string, string>
{
{ "name", "John" }
};

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().Be("Hello John, welcome!");
}

[Fact]
public void ProcessEmailTemplate_WithMultipleParameters_ShouldReplaceAll()
{
// Arrange
var template = "Hello [name], welcome to [company]!";
var parameters = new Dictionary<string, string>
{
{ "name", "John" },
{ "company", "Acme Corp" }
};

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().Be("Hello John, welcome to Acme Corp!");
}

[Fact]
public void ProcessEmailTemplate_WithParameterHavingNullValue_ShouldReplaceWithEmptyString()
{
// Arrange
var template = "Hello [name], welcome!";
var parameters = new Dictionary<string, string>
{
{ "name", null! }
};

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().Be("Hello , welcome!");
}

[Fact]
public void ProcessEmailTemplate_WithUnmatchedParameters_ShouldNotReplace()
{
// Arrange
var template = "Hello [name], welcome to [company]!";
var parameters = new Dictionary<string, string>
{
{ "name", "John" },
{ "location", "New York" } // This parameter doesn't exist in template
};

// Act
var result = _handler.ProcessEmailTemplate(template, parameters);

// Assert
result.Should().Be("Hello John, welcome to [company]!");
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<PackageReference Include="NJsonSchema" Version="11.1.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="SendGrid" Version="9.29.3" />
</ItemGroup>

<ItemGroup>
Expand All @@ -58,7 +59,10 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\blocktrust.DIDComm\Blocktrust.DIDComm\Blocktrust.DIDComm.csproj" />
<ProjectReference Include="..\..\blocktrust.Mediator\Blocktrust.Mediator.Client\Blocktrust.Mediator.Client.csproj" />
<ProjectReference Include="..\..\blocktrust.Mediator\Blocktrust.Mediator.Common\Blocktrust.Mediator.Common.csproj" />
<ProjectReference Include="..\..\blocktrust.PeerDID\Blocktrust.PeerDID\Blocktrust.PeerDID.csproj" />
<ProjectReference Include="..\Blocktrust.VerifiableCredential\Blocktrust.VerifiableCredential.csproj" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 4a6e68d

Please sign in to comment.