public void VerifyActorMockability() { var mockActorId = ActorId.CreateRandom(); ConsoleLogHelper.LogInfo("Creating Mock Actor Service..."); var mockActorService = TestMocksRepository.GetActorService <MockActor>(); ConsoleLogHelper.LogInfo("Creating Mock Actor..."); var mockActor = new MockActor(mockActorService, mockActorId); ConsoleLogHelper.LogInfo("Verifying Public Actor Members..."); mockActor.Id.Should().Be(mockActorId, "Id from Actor should be what was passed while creating the actor"); mockActor.ActorService.GetHashCode().Should().Be(mockActorService.GetHashCode(), "ActorService from actor should be what was passed while creating Actor."); mockActor.ApplicationName.Should().Be(mockActorService.Context.CodePackageActivationContext.ApplicationName, "Application Name from Actor should be same as what is coming form service's CodePackageActiviationContext"); mockActor.ServiceUri.Should().Be(mockActorService.Context.ServiceName, "ServiceUri from Actor should be same as what is coming form ServiceContext"); ConsoleLogHelper.LogInfo("Verifying Actor State Mockability..."); mockActor.VerifyActorStateMockabilityAsync().GetAwaiter().GetResult(); ConsoleLogHelper.LogInfo("Verifying Remider Mockability..."); mockActor.VerifyRemiderMockabilityAsync().GetAwaiter().GetResult(); ConsoleLogHelper.LogInfo("Verifying Timer Mockability..."); mockActor.VerifyTimerMockability(); ConsoleLogHelper.LogInfo("Verifying Actor Event Mockability..."); mockActor.VerifyActorEventMockability(); }
public void VerifyTimerMockability() { var actorTimer = TestMocksRepository.GetMockActorTimer(); Action action = () => this.UnregisterTimer(actorTimer); action.ShouldNotThrow("unregistering a timer that doesn't exist shouldn't throw."); this.RegisterTimer((obj) => Task.FromResult(true), null, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)); action = () => this.UnregisterTimer(actorTimer); action.ShouldNotThrow("unregistering an existing timer shouldn't throw"); }