Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

email action UI and classes #28

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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