Skip to content

Commit

Permalink
close #5728 fix ActorSystemSetup.And (#5729)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Mar 18, 2022
1 parent 7732b36 commit a2dc4f8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/core/Akka.Tests/Actor/Setup/ActorSystemSetupSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Akka.Actor;
using Akka.Actor.Setup;
using Akka.TestKit;
Expand Down Expand Up @@ -107,5 +108,36 @@ public void ActorSystemSettingsShouldBeAvailableFromExtendedActorSystem()
system?.Terminate().Wait(TimeSpan.FromSeconds(5));
}
}

/// <summary>
/// Reproduction for https://github.com/akkadotnet/akka.net/issues/5728
/// </summary>
[Fact]
public void ActorSystemSetupBugFix5728Reproduction()
{
// arrange
var setups = new HashSet<Akka.Actor.Setup.Setup>();
setups.Add(new DummySetup("Blantons"));
setups.Add(new DummySetup2("Colonel E.H. Taylor"));

var actorSystemSetup = ActorSystemSetup.Empty;

foreach (var s in setups)
{
actorSystemSetup = actorSystemSetup.And(s);
}

// act
var dummySetup = actorSystemSetup.Get<DummySetup>();
var dummySetup2 = actorSystemSetup.Get<DummySetup2>();

// shouldn't exist
var dummySetup3 = actorSystemSetup.Get<DummySetup3>();

// assert
dummySetup.HasValue.Should().BeTrue();
dummySetup2.HasValue.Should().BeTrue();
dummySetup3.HasValue.Should().BeFalse();
}
}
}
3 changes: 2 additions & 1 deletion src/core/Akka/Actor/Setup/ActorSystemSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public Option<T> Get<T>() where T:Setup
/// <returns>A new, immutable <see cref="ActorSystemSetup"/> instance.</returns>
public ActorSystemSetup WithSetup<T>(T setup) where T : Setup
{
return new ActorSystemSetup(_setups.SetItem(typeof(T), setup));
var typeT = setup.GetType();
return new ActorSystemSetup(_setups.SetItem(typeT, setup));
}

/// <summary>
Expand Down

0 comments on commit a2dc4f8

Please sign in to comment.