public void CanCreateInstanceWithInnerEvent() { var innerEvent = new ValueEvent(42); var instance = new VersionableEvent(innerEvent); instance.InnerEvent.Should().Be(innerEvent); }
public void InstanceIsAssignableToIEvent() { var innerEvent = new ValueEvent(42); var instance = new VersionableEvent(innerEvent); instance.Should().BeAssignableTo <IEvent>(); }
public void CanFluentlyAssignVersion() { var innerEvent = new ValueEvent(42); var instance = new VersionableEvent(innerEvent).With(2); instance.Version.Should().Be(2); }
private async void Timer_Elapsed(object sender, ElapsedEventArgs e) { this.logger.LogDebug("get: data generation event elapsed"); var topic = new TopicBuilder("playground") .With("data") .With("rng") .Build(); this.logger.LogDebug("get: generating data"); var generatedData = this.GenerateRandomData().ToList(); this.logger.LogDebug("get: generating data completed"); var watch = Stopwatch.StartNew(); this.logger.LogInformation($"get: enqueing {generatedData.Count} events"); foreach (var data in generatedData) { this.logger.LogDebug($"get: creating event for topic {topic} and data {data}"); var evt = new ValueEvent(topic, data); this.logger.LogDebug("get: enququing event"); await this.publisher.WriteAsync(evt) .ConfigureAwait(false); } this.logger.LogInformation($"get: enqueing {generatedData.Count} events completed in {watch.ElapsedMilliseconds} ms"); }
public async Task CanGetEventSubscriptions_WhenTheyHaveBeenSubscribedBefore() { Action <Type> register = t => { }; var expectedValue = 0; var @event = new ValueEvent(Value); var eventHandlerInstance = new ValueEventHandler(); var eventHandler = new Func <ValueEvent, Task>(e => { expectedValue = e.Value; return(Task.CompletedTask); }); A.CallTo(() => this.handlerRegistry.GetEventHandlers(@event)).Returns(new[] { eventHandlerInstance }); this.testee.AddEventHandler(eventHandler); this.testee.ScanAssemblyForMessageHandlers(Assembly.GetExecutingAssembly(), register); var subscriptions = this.testee.GetEventSubscriptions(@event); var tasks = subscriptions.Select(s => s.HandleAsync(@event)); await Task.WhenAll(tasks).ConfigureAwait(false); expectedValue.Should().Be(Value); eventHandlerInstance.Value.Should().Be(Value); }
public async Task CallsOutgoingPipeline_WhenPublishingEvent() { var @event = new ValueEvent(11); await this.testee.PublishAsync(@event).ConfigureAwait(false); A.CallTo(() => outgoingPipeline.InvokeAsync(@event)).MustHaveHappened(); }
public void CanCreateInstance() { var @event = new ValueEvent(42); var testee = new NoSubscriptionException(@event); testee.Should().BeAssignableTo <Exception>(); testee.Message.Should().Be("Cannot process message of type SimpleDomain.TestDoubles.ValueEvent since no subscription was found."); }
public void CanApplyChange() { var @event = new ValueEvent(11); this.testee.ApplyEvent(@event); this.testee.Value.Should().Be(11); }
public void AppliedChangeIsAddedToUncommittedEvents() { var @event = new ValueEvent(11); this.testee.ApplyEvent(@event); this.testee.UncommittedEvents.OfType <VersionableEvent>().Should().Contain(e => e.InnerEvent == @event); }
public async Task ShouldInvokeGivenFinalActionForEvent() { var message = new ValueEvent(11); var incommingMessageContext = CreateIncommingMessageContext(message); await this.testee.InvokeAsync(incommingMessageContext, null).ConfigureAwait(false); A.CallTo(() => this.finalActionForEvent.Invoke(message)).MustHaveHappened(); }
public void CanCommitUncommittedEvents() { var @event = new ValueEvent(11); this.testee.ApplyEvent(@event); this.testee.CommitEvents(); this.testee.UncommittedEvents.Should().BeEmpty(); }
public void AggregateVersionIsIncremented_WhenChangeIsApplied() { var firstEvent = new ValueEvent(11); var secondEvent = new ValueEvent(22); this.testee.ApplyEvent(firstEvent); this.testee.ApplyEvent(secondEvent); this.testee.Version.Should().Be(1); }
private bool OnEvent(ValueEvent @event, long sequence, bool endOfBatch) { _value.Value = _value.Value + @event.Value; if (_count == sequence) { _signal.Set(); } return(true); }
public void IncrementedAggregateVersionIsAppliedToEvent() { var firstEvent = new ValueEvent(11); var secondEvent = new ValueEvent(22); this.testee.ApplyEvent(firstEvent); this.testee.ApplyEvent(secondEvent); this.testee.UncommittedEvents.OfType <VersionableEvent>().First().Version.Should().Be(0); this.testee.UncommittedEvents.OfType <VersionableEvent>().Last().Version.Should().Be(1); }
internal void RemoveValueEvent(ValueEvent toRemove) { valueEvents.Remove(toRemove); if (driveType == DriveType.Directional) { dirDriveFacade.NormalizedValueChanged.RemoveListener(toRemove.floatToBoolean.DoTransform); } else { rotDriveFacade.NormalizedValueChanged.RemoveListener(toRemove.floatToBoolean.DoTransform); } DestroyImmediate(toRemove.refenceObject); }
public static ValueEvent MakeNewValueEvent(Transform parent, GameObject refrenceGameObject) { var tempEvent = new ValueEvent(); tempEvent.refenceObject = refrenceGameObject; tempEvent.refenceObject.transform.parent = parent; tempEvent.floatToBoolean = tempEvent.refenceObject.GetComponent <MyFloatToBoolean>(); tempEvent.booleanAction = tempEvent.refenceObject.GetComponent <BooleanAction>(); tempEvent.floatToBoolean.Transformed.AddListener(tempEvent.booleanAction.Receive); tempEvent.floatToBoolean.SetActivationRange(tempEvent.floatToBoolean.GetActivationRange()); return(tempEvent); }
public async Task CanStoreAndReceiveSubscriptions() { var @event = new ValueEvent(42); var testee = new InMemorySubscriptionStore(); var firstSubscriptionMessage = new SubscriptionMessage(new EndpointAddress("Queue1"), typeof(ValueEvent).FullName); var secondSubscriptionMessage = new SubscriptionMessage(new EndpointAddress("Queue2"), typeof(ValueEvent).FullName); await testee.SaveAsync(firstSubscriptionMessage).ConfigureAwait(false); await testee.SaveAsync(secondSubscriptionMessage).ConfigureAwait(false); var subscriptions = testee.GetSubscribedEndpoints(@event); subscriptions.Should() .Contain(address => address.QueueName == "Queue1").And .Contain(address => address.QueueName == "Queue2"); }
public void run() { try { cyclicBarrier.SignalAndWait(); for (long i = 0; i < iterations; i++) { long sequence = ringBuffer.Next(); ValueEvent @event = ringBuffer.Get(sequence); @event.Value = (i); ringBuffer.Publish(sequence); } } catch (Exception ex) { throw; } }
public async Task ShouldHandleEvent() { const int Value = 42; var expectedValue = 0; var valueEvent = new ValueEvent(Value); var handler = new Func <ValueEvent, Task>(cmd => { expectedValue = cmd.Value; return(Task.CompletedTask); }); var testee = new EventSubscription <ValueEvent>(handler); await testee.HandleAsync(valueEvent).ConfigureAwait(false); expectedValue.Should().Be(Value); }
public void Run() { try { cyclicBarrier.SignalAndWait(); for (long i = 0; i < iterations; i += batchSize) { long hi = ringBuffer.Next(batchSize); long lo = hi - (batchSize - 1); for (long l = lo; l <= hi; l++) { ValueEvent @event = ringBuffer.Get(l); @event.Value = (l); } ringBuffer.Publish(lo, hi); } //Console.WriteLine( "尚未到达的参与者 "+cyclicBarrier.ParticipantsRemaining+" 已到达 "+cyclicBarrier.CurrentPhaseNumber); } catch (Exception ex) { throw new ApplicationException(); } }
public void CreateValueEvent() { valueEvents.Add(ValueEvent.MakeNewValueEvent(valueEventsParent)); }
private void BtnPhieuTamVang_Click(object sender, EventArgs e) { ValueEvent?.Invoke(congDanSelected); Close(); }
public E_EventTypes GetEvent() { ValueEvent v = PropValue as ValueEvent; return(v != null ? v.Event : E_EventTypes.None); }
public void CreateValueEvent(GameObject refrenceObject) { valueEvents.Add(ValueEvent.MakeNewValueEvent(valueEventsParent, refrenceObject)); }
/// <summary> /// The example of event dispatching method /// </summary> public void Reset() { ValueEvent ve = new ValueEvent(RESET); DispatchEvent(ve); }
public void TranslateTo(ValueEvent <T> @event, long sequence, ValueEvent <T> arg0) { @event.set(arg0.get()); }
private void BtnNhanKhau_Click(object sender, EventArgs e) { ValueEvent?.Invoke(hoKhauSelected); Close(); }
public void OnEvent(ref ValueEvent data, long sequence, bool endOfBatch) => Count++;
private void BtnHoKhau_Click(object sender, EventArgs e) { ValueEvent?.Invoke(congDanSelected); Close(); }
public void OnEvent(ValueEvent <T> @event, long sequence, bool endOfBatch) { ringBuffer.PublishEvent(translator, @event); }