Skip to content

Commit

Permalink
Cleaned up TestTransport XML-DOC TBDs (#7390)
Browse files Browse the repository at this point in the history
Cleaning up some junk with the `TestTransport` and some xUnit analyzer warnings on its tests
  • Loading branch information
Aaronontheweb authored Nov 17, 2024
1 parent 36b0ec6 commit 866e053
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 140 deletions.
4 changes: 2 additions & 2 deletions src/core/Akka.Remote.Tests/Transport/TestTransportSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task TestTransport_must_return_an_Address_and_TaskCompletionSource_
Assert.NotNull(result.Item2);

var snapshot = registry.LogSnapshot();
Assert.Equal(1, snapshot.Count);
Assert.Single(snapshot);
Assert.IsType<ListenAttempt>(snapshot[0]);
Assert.Equal(_addressA, ((ListenAttempt)snapshot[0]).BoundAddress);
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public async Task TestTransport_should_emulate_disassociation()
Assert.NotNull(msg);

exists = registry.ExistsAssociation(_addressA, _addressB);
Assert.True(!exists, "Association should no longer exist");
Assert.False(exists);

var disassociateAttempt = registry.LogSnapshot().Single(x => x is DisassociateAttempt).AsInstanceOf<DisassociateAttempt>();
Assert.True(disassociateAttempt.Requestor.Equals(_addressA) && disassociateAttempt.Remote.Equals(_addressB));
Expand Down
168 changes: 30 additions & 138 deletions src/core/Akka.Remote/Transport/TestTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,22 @@ public class TestTransport : Transport
private readonly TaskCompletionSource<IAssociationEventListener> _associationListenerPromise = new();

private readonly AssociationRegistry _registry;
/// <summary>
/// TBD
/// </summary>

public readonly SwitchableLoggedBehavior<Address, AssociationHandle> AssociateBehavior;
/// <summary>
/// TBD
/// </summary>

public readonly SwitchableLoggedBehavior<TestAssociationHandle, bool> DisassociateBehavior;
/*
* Programmable behaviors
*/

/// <summary>
/// TBD
/// </summary>

public readonly SwitchableLoggedBehavior<bool, (Address, TaskCompletionSource<IAssociationEventListener>)>
ListenBehavior;

/// <summary>
/// TBD
/// </summary>

public readonly Address LocalAddress;
/// <summary>
/// TBD
/// </summary>

public readonly SwitchableLoggedBehavior<bool, bool> ShutdownBehavior;
/// <summary>
/// TBD
/// </summary>

public readonly SwitchableLoggedBehavior<(TestAssociationHandle, ByteString), bool> WriteBehavior;

/// <summary>
Expand Down Expand Up @@ -111,12 +98,7 @@ private static string GetConfigString(Config conf, string name)
throw new ConfigurationException("Please specify a value for config setting \"" + name + "\"");
return value;
}

/// <summary>
/// TBD
/// </summary>
/// <param name="remote">TBD</param>
/// <returns>TBD</returns>

public override bool IsResponsibleFor(Address remote)
{
return true;
Expand Down Expand Up @@ -297,15 +279,8 @@ public abstract class Activity
{
}

/// <summary>
/// TBD
/// </summary>
public sealed class ListenAttempt : Activity
{
/// <summary>
/// TBD
/// </summary>
/// <param name="boundAddress">TBD</param>
public ListenAttempt(Address boundAddress)
{
BoundAddress = boundAddress;
Expand All @@ -332,92 +307,48 @@ public AssociateAttempt(Address localAddress, Address remoteAddress)
RemoteAddress = remoteAddress;
LocalAddress = localAddress;
}

/// <summary>
/// TBD
/// </summary>

public Address LocalAddress { get; private set; }
/// <summary>
/// TBD
/// </summary>

public Address RemoteAddress { get; private set; }
}

/// <summary>
/// TBD
/// </summary>

public sealed class ShutdownAttempt : Activity
{
/// <summary>
/// TBD
/// </summary>
/// <param name="boundAddress">TBD</param>
public ShutdownAttempt(Address boundAddress)
{
BoundAddress = boundAddress;
}

/// <summary>
/// TBD
/// </summary>

public Address BoundAddress { get; private set; }
}

/// <summary>
/// TBD
/// </summary>

public sealed class WriteAttempt : Activity
{
/// <summary>
/// TBD
/// </summary>
/// <param name="sender">TBD</param>
/// <param name="recipient">TBD</param>
/// <param name="payload">TBD</param>
public WriteAttempt(Address sender, Address recipient, ByteString payload)
{
Payload = payload;
Recipient = recipient;
Sender = sender;
}

/// <summary>
/// TBD
/// </summary>

public Address Sender { get; private set; }
/// <summary>
/// TBD
/// </summary>

public Address Recipient { get; private set; }
/// <summary>
/// TBD
/// </summary>

public ByteString Payload { get; private set; }
}

/// <summary>
/// TBD
/// </summary>

public sealed class DisassociateAttempt : Activity
{
/// <summary>
/// TBD
/// </summary>
/// <param name="requestor">TBD</param>
/// <param name="remote">TBD</param>
public DisassociateAttempt(Address requestor, Address remote)
{
Remote = remote;
Requestor = requestor;
}

/// <summary>
/// TBD
/// </summary>

public Address Requestor { get; private set; }
/// <summary>
/// TBD
/// </summary>

public Address Remote { get; private set; }
}

Expand All @@ -429,8 +360,8 @@ public DisassociateAttempt(Address requestor, Address remote)
/// currently active behavior. The bottom of the stack always contains the <see cref="DefaultBehavior" /> which
/// can not be popped out.
/// </summary>
/// <typeparam name="TIn">TBD</typeparam>
/// <typeparam name="TOut">TBD</typeparam>
/// <typeparam name="TIn">Input type</typeparam>
/// <typeparam name="TOut">Output type</typeparam>
public class SwitchableLoggedBehavior<TIn, TOut>
{
private readonly ConcurrentStack<Func<TIn, Task<TOut>>> _behaviorStack = new();
Expand All @@ -446,19 +377,10 @@ public SwitchableLoggedBehavior(Func<TIn, Task<TOut>> defaultBehavior, Action<TI
DefaultBehavior = defaultBehavior;
_behaviorStack.Push(DefaultBehavior);
}

/// <summary>
/// TBD
/// </summary>

public Func<TIn, Task<TOut>> DefaultBehavior { get; }
/// <summary>
/// TBD
/// </summary>
public Action<TIn> LogCallback { get; }

/// <summary>
/// TBD
/// </summary>

public Func<TIn, Task<TOut>> CurrentBehavior
{
get
Expand Down Expand Up @@ -521,10 +443,7 @@ public TaskCompletionSource<bool> PushDelayed()

return controlPromise;
}

/// <summary>
/// TBD
/// </summary>

public void Pop()
{
if (_behaviorStack.Count > 1)
Expand All @@ -533,12 +452,7 @@ public void Pop()
_behaviorStack.TryPop(out behavior);
}
}

/// <summary>
/// TBD
/// </summary>
/// <param name="param">TBD</param>
/// <returns>TBD</returns>

public Task<TOut> Apply(TIn param)
{
LogCallback(param);
Expand Down Expand Up @@ -752,29 +666,15 @@ public void Reset()
_listenersTable.Clear();
}
}

/// <summary>
/// TBD
/// </summary>

public sealed class TestAssociationHandle : AssociationHandle
{
private readonly TestTransport _transport;
/// <summary>
/// TBD
/// </summary>

public readonly bool Inbound;
/// <summary>
/// TBD
/// </summary>

internal volatile bool Writeable = true;

/// <summary>
/// TBD
/// </summary>
/// <param name="localAddress">TBD</param>
/// <param name="remoteAddress">TBD</param>
/// <param name="transport">TBD</param>
/// <param name="inbound">TBD</param>

public TestAssociationHandle(Address localAddress, Address remoteAddress, TestTransport transport, bool inbound)
: base(localAddress, remoteAddress)
{
Expand All @@ -795,12 +695,7 @@ public TestAssociationHandle(Address localAddress, Address remoteAddress, TestTr
: (RemoteAddress, LocalAddress);
}
}

/// <summary>
/// TBD
/// </summary>
/// <param name="payload">TBD</param>
/// <returns>TBD</returns>

public override bool Write(ByteString payload)
{
if (Writeable)
Expand All @@ -812,10 +707,7 @@ public override bool Write(ByteString payload)

return false;
}

/// <summary>
/// TBD
/// </summary>

#pragma warning disable CS0672
public override void Disassociate()
#pragma warning restore CS0672
Expand Down

0 comments on commit 866e053

Please sign in to comment.