Skip to content

Commit

Permalink
Change namespace to Vlingo.Xoom.Common and adjusting imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tjaskula committed Apr 22, 2021
1 parent 407d779 commit 4f823d7
Show file tree
Hide file tree
Showing 79 changed files with 353 additions and 372 deletions.
30 changes: 15 additions & 15 deletions src/Vlingo.Actors.Tests/ActorLifecycleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// one at https://mozilla.org/MPL/2.0/.

using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Xunit;

namespace Vlingo.Actors.Tests
Expand Down Expand Up @@ -37,47 +37,47 @@ public void TestAfterStop()

private class TestResults
{
private readonly AtomicBoolean receivedBeforeStart = new AtomicBoolean(false);
private readonly AtomicBoolean receivedAfterStop = new AtomicBoolean(false);
internal readonly AccessSafely received;
private readonly AtomicBoolean _receivedBeforeStart = new AtomicBoolean(false);
private readonly AtomicBoolean _receivedAfterStop = new AtomicBoolean(false);
internal readonly AccessSafely Received;

private TestResults(AccessSafely received)
{
this.received = received;
this.Received = received;
}

public static TestResults AfterCompleting(int times)
{
var testResults = new TestResults(AccessSafely.AfterCompleting(times));
testResults.received.WritingWith<bool>("receivedBeforeStart", testResults.receivedBeforeStart.Set);
testResults.received.ReadingWith("receivedBeforeStart", testResults.receivedBeforeStart.Get);
testResults.received.WritingWith<bool>("receivedAfterStop", testResults.receivedAfterStop.Set);
testResults.received.ReadingWith("receivedAfterStop", testResults.receivedAfterStop.Get);
testResults.Received.WritingWith<bool>("receivedBeforeStart", testResults._receivedBeforeStart.Set);
testResults.Received.ReadingWith("receivedBeforeStart", testResults._receivedBeforeStart.Get);
testResults.Received.WritingWith<bool>("receivedAfterStop", testResults._receivedAfterStop.Set);
testResults.Received.ReadingWith("receivedAfterStop", testResults._receivedAfterStop.Get);
return testResults;
}

public bool GetReceivedBeforeStart() => received.ReadFrom<bool>("receivedBeforeStart");
public bool GetReceivedBeforeStart() => Received.ReadFrom<bool>("receivedBeforeStart");

public bool GetReceivedAfterStop() => received.ReadFrom<bool>("receivedAfterStop");
public bool GetReceivedAfterStop() => Received.ReadFrom<bool>("receivedAfterStop");
}

private class LifecycleActor : Actor, IStoppable
{
private readonly TestResults testResults;
private readonly TestResults _testResults;

public LifecycleActor(TestResults testResults)
{
this.testResults = testResults;
this._testResults = testResults;
}

protected internal override void BeforeStart()
{
testResults.received.WriteUsing("receivedBeforeStart", true);
_testResults.Received.WriteUsing("receivedBeforeStart", true);
}

protected internal override void AfterStop()
{
testResults.received.WriteUsing("receivedAfterStop", true);
_testResults.Received.WriteUsing("receivedAfterStop", true);
}
}
}
Expand Down
68 changes: 34 additions & 34 deletions src/Vlingo.Actors.Tests/ActorStopTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.

using Vlingo.Common;
using Vlingo.Xoom.Common;
using Vlingo.Actors.TestKit;
using Xunit;

Expand Down Expand Up @@ -86,92 +86,92 @@ private IChildCreatingStoppable[] SetUpActors(World world, TestResults results)

private class ChildCreatingStoppableActor : Actor, IChildCreatingStoppable
{
private readonly TestResults results;
private readonly TestResults _results;

public ChildCreatingStoppableActor(TestResults results)
{
this.results = results;
this._results = results;
}

public void CreateChildren()
{
var pre = Address.Name;
ChildActorFor<IChildCreatingStoppable>(Definition.Has<ChildCreatingStoppableActor>(Definition.Parameters(results), $"{pre}.1"));
ChildActorFor<IChildCreatingStoppable>(Definition.Has<ChildCreatingStoppableActor>(Definition.Parameters(results), $"{pre}.2"));
ChildActorFor<IChildCreatingStoppable>(Definition.Has<ChildCreatingStoppableActor>(Definition.Parameters(results), $"{pre}.3"));
ChildActorFor<IChildCreatingStoppable>(Definition.Has<ChildCreatingStoppableActor>(Definition.Parameters(_results), $"{pre}.1"));
ChildActorFor<IChildCreatingStoppable>(Definition.Has<ChildCreatingStoppableActor>(Definition.Parameters(_results), $"{pre}.2"));
ChildActorFor<IChildCreatingStoppable>(Definition.Has<ChildCreatingStoppableActor>(Definition.Parameters(_results), $"{pre}.3"));
}

protected internal override void BeforeStart()
{
base.BeforeStart();
results.beforeStartCountAccess.WriteUsing("value", 1);
_results.BeforeStartCountAccess.WriteUsing("value", 1);
}

protected internal override void AfterStop()
{
if (results.terminatingAccess.ReadFromNow<bool>("value"))
if (_results.TerminatingAccess.ReadFromNow<bool>("value"))
{
results.terminatingStopCountAccess.WriteUsing("value", 1);
_results.TerminatingStopCountAccess.WriteUsing("value", 1);
}
else
{
results.stopCountAccess.WriteUsing("value", 1);
_results.StopCountAccess.WriteUsing("value", 1);
}
}
}

private class TestResults
{
internal AccessSafely beforeStartCountAccess = AccessSafely.AfterCompleting(1);
internal AtomicInteger beforeStartCount = new AtomicInteger(0);
internal AccessSafely BeforeStartCountAccess = AccessSafely.AfterCompleting(1);
internal readonly AtomicInteger BeforeStartCount = new AtomicInteger(0);

internal AccessSafely stopCountAccess = AccessSafely.AfterCompleting(1);
internal AtomicInteger stopCount = new AtomicInteger(0);
internal AccessSafely StopCountAccess = AccessSafely.AfterCompleting(1);
internal readonly AtomicInteger StopCount = new AtomicInteger(0);

internal AccessSafely terminatingAccess = AccessSafely.AfterCompleting(1);
internal AtomicBoolean terminating = new AtomicBoolean(false);
internal AccessSafely TerminatingAccess = AccessSafely.AfterCompleting(1);
internal readonly AtomicBoolean Terminating = new AtomicBoolean(false);

internal AccessSafely terminatingStopCountAccess = AccessSafely.AfterCompleting(1);
internal AtomicInteger terminatingStopCount = new AtomicInteger(0);
internal AccessSafely TerminatingStopCountAccess = AccessSafely.AfterCompleting(1);
internal readonly AtomicInteger TerminatingStopCount = new AtomicInteger(0);

public AccessSafely BeforeStartCountAccessCompletes(int times)
{
beforeStartCountAccess = AccessSafely
BeforeStartCountAccess = AccessSafely
.AfterCompleting(times)
.WritingWith("value", (int value) => beforeStartCount.Set(beforeStartCount.Get() + value))
.ReadingWith("value", () => beforeStartCount.Get());
.WritingWith("value", (int value) => BeforeStartCount.Set(BeforeStartCount.Get() + value))
.ReadingWith("value", () => BeforeStartCount.Get());

return beforeStartCountAccess;
return BeforeStartCountAccess;
}

public AccessSafely StopCountAccessCompletes(int times)
{
stopCountAccess = AccessSafely
StopCountAccess = AccessSafely
.AfterCompleting(times)
.WritingWith("value", (int value) => stopCount.Set(stopCount.Get() + value))
.ReadingWith("value", () => stopCount.Get());
.WritingWith("value", (int value) => StopCount.Set(StopCount.Get() + value))
.ReadingWith("value", () => StopCount.Get());

return stopCountAccess;
return StopCountAccess;
}

public AccessSafely TerminatingAccessCompletes(int times)
{
terminatingAccess = AccessSafely
TerminatingAccess = AccessSafely
.AfterCompleting(times)
.WritingWith("value", (bool flag) => terminating.Set(flag))
.ReadingWith("value", () => terminating.Get());
.WritingWith("value", (bool flag) => Terminating.Set(flag))
.ReadingWith("value", () => Terminating.Get());

return terminatingAccess;
return TerminatingAccess;
}

public AccessSafely TerminatingStopCountAccessCompletes(int times)
{
terminatingStopCountAccess = AccessSafely
TerminatingStopCountAccess = AccessSafely
.AfterCompleting(times)
.WritingWith("value", (int value) => terminatingStopCount.Set(terminatingStopCount.Get() + value))
.ReadingWith("value", () => terminatingStopCount.Get());
.WritingWith("value", (int value) => TerminatingStopCount.Set(TerminatingStopCount.Get() + value))
.ReadingWith("value", () => TerminatingStopCount.Get());

return terminatingStopCountAccess;
return TerminatingStopCountAccess;
}
}
}
Expand Down
44 changes: 22 additions & 22 deletions src/Vlingo.Actors.Tests/ActorStowDisperseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using System;
using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Xunit;

namespace Vlingo.Actors.Tests
Expand All @@ -30,8 +30,8 @@ public void TestThatStowedMessagesDisperseOnOverride()

protocols._2.Override();

Assert.Equal(1, results.overrideAccess.ReadFrom<int>("overrideReceivedCount"));
Assert.Equal(10, results.stowedAccess.ReadFrom<int>("stowReceivedCount"));
Assert.Equal(1, results.OverrideAccess.ReadFrom<int>("overrideReceivedCount"));
Assert.Equal(10, results.StowedAccess.ReadFrom<int>("stowReceivedCount"));
}

[Fact]
Expand All @@ -50,59 +50,59 @@ public void TestThatStowedMessagesDisperseOnCrash()

protocols._2.Crash();

Assert.Equal(1, results.overrideAccess.ReadFrom<int>("overrideReceivedCount"));
Assert.Equal(10, results.stowedAccess.ReadFrom<int>("stowReceivedCount"));
Assert.Equal(1, results.OverrideAccess.ReadFrom<int>("overrideReceivedCount"));
Assert.Equal(10, results.StowedAccess.ReadFrom<int>("stowReceivedCount"));
}

private class Results
{
public readonly AccessSafely overrideAccess;
public readonly AccessSafely stowedAccess;
public readonly AtomicInteger overrideReceivedCount;
public readonly AtomicInteger stowReceivedCount;
public readonly AccessSafely OverrideAccess;
public readonly AccessSafely StowedAccess;
public readonly AtomicInteger OverrideReceivedCount;
public readonly AtomicInteger StowReceivedCount;

public Results(int overrideReceived, int stowReceived)
{
overrideReceivedCount = new AtomicInteger(0);
stowReceivedCount = new AtomicInteger(0);
OverrideReceivedCount = new AtomicInteger(0);
StowReceivedCount = new AtomicInteger(0);

stowedAccess = AccessSafely
StowedAccess = AccessSafely
.AfterCompleting(stowReceived)
.WritingWith("stowReceivedCount", (int increment) => stowReceivedCount.Set(stowReceivedCount.Get() + increment))
.ReadingWith("stowReceivedCount", () => stowReceivedCount.Get());
.WritingWith("stowReceivedCount", (int increment) => StowReceivedCount.Set(StowReceivedCount.Get() + increment))
.ReadingWith("stowReceivedCount", () => StowReceivedCount.Get());

overrideAccess = AccessSafely
OverrideAccess = AccessSafely
.AfterCompleting(overrideReceived)
.WritingWith("overrideReceivedCount", (int increment) => overrideReceivedCount.Set(overrideReceivedCount.Get() + increment))
.ReadingWith("overrideReceivedCount", () => overrideReceivedCount.Get());
.WritingWith("overrideReceivedCount", (int increment) => OverrideReceivedCount.Set(OverrideReceivedCount.Get() + increment))
.ReadingWith("overrideReceivedCount", () => OverrideReceivedCount.Get());
}
}

private class StowTestActor : Actor, IOverrideStowage, IStowThese
{
private readonly Results results;
private readonly Results _results;

public StowTestActor(Results results)
{
this.results = results;
_results = results;
StowMessages(typeof(IOverrideStowage));
}

public void Crash()
{
results.overrideAccess.WriteUsing("overrideReceivedCount", 1);
_results.OverrideAccess.WriteUsing("overrideReceivedCount", 1);
throw new ApplicationException("Intended failure");
}

public void Override()
{
results.overrideAccess.WriteUsing("overrideReceivedCount", 1);
_results.OverrideAccess.WriteUsing("overrideReceivedCount", 1);
DisperseStowedMessages();
}

public void Stow()
{
results.stowedAccess.WriteUsing("stowReceivedCount", 1);
_results.StowedAccess.WriteUsing("stowReceivedCount", 1);
}

protected internal override void BeforeResume(Exception reason)
Expand Down
6 changes: 3 additions & 3 deletions src/Vlingo.Actors.Tests/AnswerEventuallyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

using System;
using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Xunit;

namespace Vlingo.Actors.Tests
{
public class AnswerEventuallyTest : IDisposable
{
private AtomicInteger _value = new AtomicInteger(0);
private IAnswerGiver _answerGiver;
private readonly AtomicInteger _value = new AtomicInteger(0);
private readonly IAnswerGiver _answerGiver;
private readonly World _world;

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/Vlingo.Actors.Tests/BroadcastRouterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// one at https://mozilla.org/MPL/2.0/.

using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Xunit;

namespace Vlingo.Actors.Tests
Expand Down
2 changes: 1 addition & 1 deletion src/Vlingo.Actors.Tests/CharactersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using System.Collections.Generic;
using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Xunit;

namespace Vlingo.Actors.Tests
Expand Down
2 changes: 1 addition & 1 deletion src/Vlingo.Actors.Tests/CompletesActorProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using System;
using System.Threading;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Vlingo.Actors.TestKit;
using Xunit;

Expand Down
4 changes: 2 additions & 2 deletions src/Vlingo.Actors.Tests/GuidAddressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

using System;
using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Common.Identity;
using Vlingo.Xoom.Common;
using Vlingo.Xoom.Common.Identity;
using Xunit;

namespace Vlingo.Actors.Tests
Expand Down
2 changes: 1 addition & 1 deletion src/Vlingo.Actors.Tests/LocalMessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System;
using System.Threading;
using Vlingo.Actors.TestKit;
using Vlingo.Common;
using Vlingo.Xoom.Common;
using Xunit;

namespace Vlingo.Actors.Tests
Expand Down
Loading

0 comments on commit 4f823d7

Please sign in to comment.