Skip to content

Commit

Permalink
Removed Scrapbook work extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
stidsborg committed Dec 9, 2023
1 parent e74416f commit 6744527
Show file tree
Hide file tree
Showing 34 changed files with 145 additions and 733 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@ public override Task CompletedAtLeastOnceWorkIsNotExecutedMultipleTimes()
[TestMethod]
public override Task CompletedAtLeastOnceWorkWithCallIdIsNotExecutedMultipleTimes()
=> CompletedAtLeastOnceWorkWithCallIdIsNotExecutedMultipleTimes(Utils.CreateInMemoryFunctionStoreTask());

[TestMethod]
public override Task ReferencingGetOnlyPropertyThrowsException()
=> ReferencingGetOnlyPropertyThrowsException(Utils.CreateInMemoryFunctionStoreTask());
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ public override Task CompletedAtLeastOnceWorkIsNotExecutedMultipleTimes()
[TestMethod]
public override Task CompletedAtLeastOnceWorkWithCallIdIsNotExecutedMultipleTimes()
=> CompletedAtLeastOnceWorkWithCallIdIsNotExecutedMultipleTimes(Utils.CreateInMemoryFunctionStoreTask());

[TestMethod]
public override Task ReferencingGetOnlyPropertyThrowsException()
=> ReferencingGetOnlyPropertyThrowsException(Utils.CreateInMemoryFunctionStoreTask());
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@ public override Task CompletedAtMostOnceWorkWithCallIdIsNotExecutedMultipleTimes
[TestMethod]
public override Task CompletedAtMostOnceWorkWithCallIdAndGenericResultIsNotExecutedMultipleTimes()
=> CompletedAtMostOnceWorkWithCallIdAndGenericResultIsNotExecutedMultipleTimes(Utils.CreateInMemoryFunctionStoreTask());

[TestMethod]
public override Task ReferencingGetOnlyPropertyThrowsException()
=> ReferencingGetOnlyPropertyThrowsException(Utils.CreateInMemoryFunctionStoreTask());
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ public override Task AtMostOnceWorkWithCallIdIsNotExecutedMultipleTimes()
[TestMethod]
public override Task CompletedAtMostOnceWorkIsNotExecutedMultipleTimes()
=> CompletedAtMostOnceWorkIsNotExecutedMultipleTimes(Utils.CreateInMemoryFunctionStoreTask());

[TestMethod]
public override Task ReferencingGetOnlyPropertyThrowsException()
=> ReferencingGetOnlyPropertyThrowsException(Utils.CreateInMemoryFunctionStoreTask());
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public async Task AtLeastOnceWorkIsExecutedMultipleTimesWhenNotCompleted(Task<IF

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workStatus: s => s.WorkStatus,
await context.Activity
.Do(
"id",
work: () =>
{
counter.Increment();
Expand All @@ -48,7 +48,7 @@ await BusyWait.Until(() =>
);

var controlPanel = await rAction.ControlPanel(functionInstanceId);
controlPanel!.Scrapbook.WorkStatus.Result.ShouldBe(1);
controlPanel!.Activities.SelectAsync(a => a.GetValue<int>("id")).Result.ShouldBe(1);
counter.Current.ShouldBe(2);
}

Expand All @@ -63,11 +63,11 @@ public async Task AtLeastOnceWorkWithCallIdIsExecutedMultipleTimesWhenNotComplet

var rFunc = rFunctions.RegisterFunc(
functionTypeId,
async Task<string>(string param, Scrapbook scrapbook) =>
async Task<string>(string param, Context context) =>
{
return await scrapbook
.DoAtLeastOnce(
workId: "someId",
return await context.Activity
.Do(
"someId",
work: () =>
{
counter.Increment();
Expand Down Expand Up @@ -103,11 +103,11 @@ public async Task AtLeastOnceWorkWithCallIdAndGenericResultIsExecutedMultipleTim

var rFunc = rFunctions.RegisterFunc(
functionTypeId,
async Task<Person>(string param, Scrapbook scrapbook) =>
async Task<Person>(string param, Context context) =>
{
return await scrapbook
.DoAtLeastOnce(
workId: "someId",
return await context.Activity
.Do(
"someId",
work: () =>
{
counter.Increment();
Expand Down Expand Up @@ -146,12 +146,13 @@ public async Task CompletedAtLeastOnceWorkIsNotExecutedMultipleTimes(Task<IFunct

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workStatus: s => s.WorkStatus,
work: () => { counter.Increment(); return 1.ToTask(); });
await context.Activity
.Do(
"id",
work: () => { counter.Increment(); return 1.ToTask(); }
);
});

await rAction.Invoke(functionInstanceId.ToString(), "hello");
Expand All @@ -172,11 +173,11 @@ public async Task CompletedAtLeastOnceWorkWithCallIdIsNotExecutedMultipleTimes(T

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workId: "someId",
await context.Activity
.Do(
"someId",
work: () => { counter.Increment(); return "hello world".ToTask(); }
);
});
Expand All @@ -188,32 +189,8 @@ await scrapbook
await controlPanel.ReInvoke();
await controlPanel.Refresh();

var value = controlPanel.Scrapbook.StateDictionary["someId"];
var splitValue = value.Split(",");
splitValue[0].ShouldBe(WorkStatus.Completed.ToString());
splitValue[1].ShouldBe("hello world");
var value = await controlPanel.Activities.SelectAsync(a => a.GetValue<string>("someId"));
value.ShouldBe("hello world");
counter.Current.ShouldBe(1);
}

public abstract Task ReferencingGetOnlyPropertyThrowsException();
public async Task ReferencingGetOnlyPropertyThrowsException(Task<IFunctionStore> storeTask)
{
var scrapbook = new ScrapbookGetterOnly();
await Should.ThrowAsync<ArgumentException>(() =>
scrapbook.DoAtMostOnce(
workStatus: s => s.WorkStatus,
work: () => 1.ToTask()
)
);
}

private class Scrapbook : RScrapbook
{
public Work<int> WorkStatus { get; set; }
}

private class ScrapbookGetterOnly : RScrapbook
{
public Work<int> WorkStatus { get; } = new();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public async Task AtLeastOnceWorkIsExecutedMultipleTimesWhenNotCompleted(Task<IF

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workStatus: s => s.WorkStatus,
await context.Activity
.Do(
"Id",
work: () =>
{
counter.Increment();
Expand Down Expand Up @@ -60,11 +60,11 @@ public async Task AtLeastOnceWorkWithCallIdIsExecutedMultipleTimesWhenNotComplet

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workId: "someId",
await context.Activity
.Do(
"someId",
work: () =>
{
counter.Increment();
Expand Down Expand Up @@ -96,11 +96,11 @@ public async Task CompletedAtLeastOnceWorkIsNotExecutedMultipleTimes(Task<IFunct

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workStatus: s => s.WorkStatus,
await context.Activity
.Do(
"Id",
work: () => { counter.Increment(); return Task.CompletedTask; });
});

Expand All @@ -121,11 +121,11 @@ public async Task CompletedAtLeastOnceWorkWithCallIdIsNotExecutedMultipleTimes(T

var rAction = rFunctions.RegisterAction(
functionTypeId,
async Task(string param, Scrapbook scrapbook) =>
async Task(string param, Context context) =>
{
await scrapbook
.DoAtLeastOnce(
workId: "someId",
await context.Activity
.Do(
"someId",
work: () => { counter.Increment(); return Task.CompletedTask; });
});

Expand All @@ -134,26 +134,4 @@ await scrapbook

counter.Current.ShouldBe(1);
}

public abstract Task ReferencingGetOnlyPropertyThrowsException();
public async Task ReferencingGetOnlyPropertyThrowsException(Task<IFunctionStore> functionStoreTask)
{
var scrapbook = new ScrapbookGetterOnly();
await Should.ThrowAsync<ArgumentException>(() =>
scrapbook.DoAtMostOnce(
workStatus: s => s.WorkStatus,
work: () => Task.CompletedTask
)
);
}

private class Scrapbook : RScrapbook
{
public WorkStatus WorkStatus { get; set; }
}

private class ScrapbookGetterOnly : RScrapbook
{
public WorkStatus WorkStatus { get; } = WorkStatus.NotStarted;
}
}
Loading

0 comments on commit 6744527

Please sign in to comment.