Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions Tests/Runtime/Util/ShouldPostExceptionImplTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BugSplatUnity.Runtime.Util;
using NUnit.Framework;
using System;
using System.Reflection;
using System.Threading;

namespace BugSplatUnity.RuntimeTests.Util
{
class ShouldPostExceptionImplTests
{
// TODO
[Test]
public void DefaultShouldPostExceptionImpl_ShouldRespectRateLimiting()
{
// Reset internal lastPost field to ensure test independence
var field = typeof(ShouldPostExceptionImpl).GetField("lastPost", BindingFlags.NonPublic | BindingFlags.Static);
field.SetValue(null, new DateTime(0));

// First call should be allowed
Assert.IsTrue(ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl());

// Second immediate call should be blocked
Assert.IsFalse(ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl());

// After waiting for 3 seconds a subsequent call should be allowed
Thread.Sleep(TimeSpan.FromSeconds(3));
Assert.IsTrue(ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl());
}
}
}