Skip to content

Commit

Permalink
feat(dotnet-sdk): rename tests and refactor masking example
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlaCarvajal committed Nov 27, 2024
1 parent 8faf304 commit 8947d59
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion sdk-dotnet/Examples/ExceptionsHandlerExample/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void FailNewProcess()
public void FailForTechnicalReason()
{
String message = null!;
int result = message!.Length;
int result = message.Length;
Console.WriteLine(result);
}

Expand Down
45 changes: 27 additions & 18 deletions sdk-dotnet/Examples/MaskedFieldsExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using LittleHorse.Sdk;
using LittleHorse.Sdk.Worker;
using MaskedFieldsExample;

public class Program
namespace MaskedFieldsExample;

public abstract class Program
{
private static ServiceProvider? _serviceProvider;
private static void SetupApplication()
Expand All @@ -26,6 +27,19 @@ private static LHConfig GetLHConfig(string[] args, ILoggerFactory loggerFactory)

return config;
}

private static List<LHTaskWorker<MyWorker>> GetTaskWorkers(LHConfig config)
{
MyWorker executableExceptionHandling = new MyWorker();
var workers = new List<LHTaskWorker<MyWorker>>
{
new(executableExceptionHandling, "create-greet", config),
new(executableExceptionHandling, "update-greet", config),
new(executableExceptionHandling, "delete-greet", config)
};

return workers;
}

static void Main(string[] args)
{
Expand All @@ -34,23 +48,18 @@ static void Main(string[] args)
{
var loggerFactory = _serviceProvider.GetRequiredService<ILoggerFactory>();
var config = GetLHConfig(args, loggerFactory);
var workers = GetTaskWorkers(config);
foreach (var worker in workers)
{
worker.RegisterTaskDef();
}

MyWorker executableCreateGreet = new MyWorker();
var taskWorkerCreate = new LHTaskWorker<MyWorker>(executableCreateGreet, "create-greet", config);
MyWorker executableUpdateGreet = new MyWorker();
var taskWorkerUpdate = new LHTaskWorker<MyWorker>(executableUpdateGreet, "update-greet", config);
MyWorker executableDeleteGreet = new MyWorker();
var taskWorkerDelete = new LHTaskWorker<MyWorker>(executableDeleteGreet, "delete-greet", config);

taskWorkerCreate.RegisterTaskDef();
taskWorkerUpdate.RegisterTaskDef();
taskWorkerDelete.RegisterTaskDef();
Thread.Sleep(300);

Thread.Sleep(1000);

taskWorkerCreate.Start();
taskWorkerUpdate.Start();
taskWorkerDelete.Start();
foreach (var worker in workers)
{
worker.Start();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void LHHelper_WithSystemBytesVariableType_ShouldReturnLHVariableBytesType
}

[Fact]
public void LHHelper_WithSystemArrayObjectVariableType_ShouldReturnLHVariableJsonArrType()
public void LHHelper_WithSystemVoidVariableType_ShouldReturnLHVariableJsonObjType()
{
var type = typeof(void);

Expand All @@ -81,7 +81,7 @@ public void LHHelper_WithSystemArrayObjectVariableType_ShouldReturnLHVariableJso
}

[Fact]
public void LHHelper_WithSystemVoidVariableType_ShouldReturnLHVariableJsonObjType()
public void LHHelper_WithSystemArrayObjectVariableType_ShouldReturnLHVariableJsonArrType()
{
var test_allowed_types = new List<Type>() { typeof(List<object>), typeof(List<string>), typeof(List<int>)};

Expand Down

0 comments on commit 8947d59

Please sign in to comment.