Skip to content

Commit

Permalink
Store array resize fix (#1908) (#1909)
Browse files Browse the repository at this point in the history
* Fix array resize bug (#1908)

* add store test class
  • Loading branch information
arkadiuszwojcik committed Jan 23, 2023
1 parent 3a998bc commit 6c504cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Proto.Actor/Utils/TypedDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Add<TKey>(TValue value)

if (id >= _values.Length)
{
Array.Resize(ref _values, (int)(id * _growthFactor));
Array.Resize(ref _values, (int)((id + 1) * _growthFactor));
}

_values[id] = value;
Expand Down
24 changes: 24 additions & 0 deletions tests/Proto.Actor.Tests/StoreTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Threading.Tasks;
using Xunit;

namespace Proto.Tests;

public class StoreTests
{
[Fact]
public async Task Given_RootContextStore_SetAndGetCustomObject()
{
await using var system = new ActorSystem();
var context = system.Root;

var toStore = new StoreType();
context.Set(toStore);
var fromStore = context.Get<StoreType>();

Assert.Same(toStore, fromStore);
}

class StoreType
{
}
}

0 comments on commit 6c504cf

Please sign in to comment.