async Task ConcreteMessage(IPipelineContext context) { #region InstancePublish MyEvent message = new MyEvent { SomeProperty = "Hello world" }; await context.Publish(message); #endregion }
void ConcreteMessage(IBus bus) { #region InstancePublish MyEvent message = new MyEvent { SomeProperty = "Hello world" }; bus.Publish(message); #endregion }
static void Start(IBus bus) { Console.WriteLine("Press 'p' to Publish MyEvent"); Console.WriteLine("Press 's' to SendLocal MyMessage"); Console.WriteLine("Press any other key to exit"); while (true) { var key = Console.ReadKey(); Console.WriteLine(); var id = Guid.NewGuid(); if (key.Key == ConsoleKey.P) { var myEvent = new MyEvent { Id = id, }; bus.Publish(myEvent); Console.WriteLine("Published MyEvent with Id {0}.", id); continue; } if (key.Key == ConsoleKey.S) { var eventMessage = new MyMessage { Id = id, }; bus.SendLocal(eventMessage); Console.WriteLine("Sent MyMessage with Id {0}.", id); continue; } return; } }
private async Task Throw(Exception ex) { var msg = new MyEvent(); _processor.When(d => d.Process(msg, Arg.Any<string>())).Throw((dynamic) ex); await _sut.Queue(msg); _sut.WaitUntilWorkersFinish(); _errors.Received(1).MessageCantBeHandled(msg,(dynamic)ex); }
public async Task runs_normally() { var msg = new MyEvent(); await _sut.Queue(msg); _sut.WaitUntilWorkersFinish(); _processor.Received(1).Process(msg,_sut.Name); _storage.Received(1).MarkMessageHandled(_sut.Name,msg.Id); }
static void Main(string[] args) { MyEvent mailEvent = new MyEvent(); mailEvent.myEvent += OnNewMail; mailEvent.OnEventCoplete("Hello, my dear Lena!"); Console.ReadLine(); }
public async Task ConcreteMessage() { IBusContext busContext = null; #region InstancePublish MyEvent message = new MyEvent { SomeProperty = "Hello world" }; await busContext.Publish(message); #endregion }
public void ConcreteMessage() { IBus bus = null; #region InstancePublish var message = new MyEvent { SomeProperty = "Hello world" }; bus.Publish(message); #endregion }
public async Task ConcreteMessage() { IBus bus = null; #region InstancePublish var message = new MyEvent { SomeProperty = "Hello world" }; await bus.PublishAsync(message); #endregion }
private void TestEventFunc(MyEvent ev) { if (_unsubscribe) { Unsubscribe(); _unsubscribe = false; } _counter++; }
public Chapter8() { MyEvent evt = new MyEvent(); // Add Handler() to the event list. evt.SomeEvent += Handler; // Raise the event. evt.OnSomeEvent(); }
public void fireEvent(MyEvent ev,params Object[] param) { if (hash[(int)ev] == null) return; List<IEvent> list = (List<IEvent>)hash[(int)ev]; Event eve = new Event(ev,param); foreach (IEvent ie in list) { ie.addEvent(eve); } }
protected void btnMakeEvent_Click(object sender, EventArgs e) { String eventName = txtEventName.Text; int firstSeatNum = Convert.ToInt16(txtFirstSeat.Text); int lastSeatNum = Convert.ToInt16(txtLastSeat.Text); newEvent = new MyEvent(eventName, firstSeatNum, lastSeatNum); Session["Event"] = newEvent; lblAvailTickets.Text = newEvent.NumAvailSeats.ToString(); ddlSeats.DataSource = newEvent.AvailSeats; ddlSeats.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { newEvent = Session["Event"] as MyEvent; if ((newEvent != null) && (!Page.IsPostBack)) { ddlSeats.DataSource = newEvent.AvailSeats; ddlSeats.DataBind(); lblAvailTickets.Text = newEvent.NumAvailSeats.ToString(); } }
public void tryingToRaiseAnEvent() { var bus = new EventBus(); bus.specificSubscriber += subscribingMethod; var @event = new MyEvent(); bus.publish(@event); @event.SubscriberWasCalled.Should().BeTrue(); }
public static void EventDemoStart() { MyEvent evt = new MyEvent(); evt.SomeEvent += EventDemoHandler; evt.SomeEvent += delegate() { Console.WriteLine("Anonimus"); }; evt.HogaEvent += HogaHoga; evt.Fire(); }
public static void Main() { MyEvent evt = new MyEvent(); // Add handler() to the event list. evt.SomeEvent += new MyEventHandler(handler); // Fire the event. evt.OnSomeEvent(); evt.SomeEvent -= handler; evt.OnSomeEvent(); Console.ReadKey(); }
public async Task messages_are_sent_local_and_server() { var myEvent = new MyEvent(); var command = new MyCommand(); EnvelopeFromClient env = null; await _server.SendMessages(Arg.Do<EnvelopeFromClient>(e => env = e)); await _sut.Dispatch(myEvent,command); await _config.Received(1).AddToProcessing(Arg.Any<MyEvent>(), Arg.Any<MyCommand>()); await _server.ReceivedWithAnyArgs(1).SendMessages(null); env.From.Should().Be(Setup.TestEndpoint.Host); env.Messages.ShouldAllBeEquivalentTo(new IMessage[] {myEvent,command}); }
static void Main() { MyEvent evt = new MyEvent(); X xOb = new X(); Y yOb = new Y(); evt.SomeEvent += Handler; evt.SomeEvent += xOb.Xhandler; evt.SomeEvent += yOb.Yhandler; evt.Fire(); evt.SomeEvent -= xOb.Xhandler; evt.Fire(); }
protected void Page_Load(object sender, EventArgs e) { currentEvent = Session["Event"] as MyEvent; tickets = currentEvent.Tickets; if (!Page.IsPostBack) { lblEventName.Text = currentEvent.Name; ddlBuyer.DataSource = tickets; ddlBuyer.DataTextField = "name"; ddlBuyer.DataValueField = "name"; ddlBuyer.DataBind(); txtSummary.Text = display_summary("purchase"); } }
public async Task when_data_storage_throws_service_doesnt_stop() { var msg = new MyEvent(); _storage.When(d => d.MarkMessageHandled(Arg.Any<string>(), msg.Id)).Throw<BusStorageException>(); await _sut.Queue(msg); _sut.WaitUntilWorkersFinish(); var other = new MyEvent(); var ok = false; _storage.When(d => d.MarkMessageHandled(Arg.Any<string>(), other.Id)).Do(i=>ok=true); await _sut.Queue(other); _sut.WaitUntilWorkersFinish(); ok.Should().BeTrue(); }
public async Task messages_arent_sent_back_to_origin() { var myEvent = new MyEvent(); var env=new EnvelopeFromClient() { From =Setup.TestEndpoint.Host, Messages = new IMessage[] {myEvent,new OtherEvent()} }; EnvelopeToClient dest = null; await _sut.Route(env); await _transporter.DidNotReceiveWithAnyArgs().Send(null); }
/// <summary> /// Constructor of the Event class. /// </summary> /// <param name="id">the id of the event.</param> /// <param name="kv">the set of args</param> public Event(MyEvent id, params Object[] kv) { this.eventId = id; if (kv.Length == 0) { this.args = null; } else { this.args = new Hashtable(); for (int i = 0; i < kv.Length; i += 2) { this.args[kv[i]] = kv[i + 1]; } } }
public async Task routing_messages_for_each_endpoint() { var myEvent = new MyEvent(); var env=new EnvelopeFromClient() { From ="some host", Messages = new IMessage[] {myEvent,new OtherEvent()} }; EnvelopeToClient dest = null; await _transporter.Send(Arg.Do<EnvelopeToClient>(e => dest = e)); await _sut.Route(env); dest.To.Should().Be(Setup.TestEndpoint); dest.Messages.ShouldAllBeEquivalentTo(new[] {myEvent}); }
public void load_from_storage() { _sut.Stop(); _sut.PollingEnabled = true; _sut.PollingInterval = 100.ToMiliseconds(); var queue=new Queue<IMessage>(); var myEvent = new MyEvent(); queue.Enqueue(myEvent); var myCommand = new MyCommand(); queue.Enqueue(myCommand); _storage.GetMessages(_sut.Name, Arg.Any<int>()).Returns(i => new [] { queue.Dequeue()}); _sut.Start(); _sut.WaitUntilWorkersFinish(); _processor.Received(1).Process(myEvent,_sut.Name); _processor.Received(1).Process(myCommand,_sut.Name); }
public void PublishAsync_Where_No_Publication_Configurations_Which_Results_In_A_NoConfigurationFound_Result() { var _busConfigurationBuilder = new BusConfigurationBuilder(); _busConfigurationBuilder.ConnectionUris.Add(TestingConfiguration.LocalConnectionUri); var _busConfirguration = _busConfigurationBuilder.Build(); var _connectionManager = Substitute.For<IConnectionManager>(); var _context = Substitute.For<IBusContext>(); var _SUT = new Connected( _busConfirguration, _connectionManager, _context); var _theEvent = new MyEvent(Guid.NewGuid(), null, "Some detail", 1); var _publicationResult = _SUT.PublishAsync(_theEvent); _publicationResult.Wait(); Assert.AreEqual(PMCG.Messaging.PublicationResultStatus.NoConfigurationFound, _publicationResult.Result.Status); }
public void Establish() { _channel = new FakeChannel(); _commandProcessor = new SpyCommandProcessor(); var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory(() => new MyEventMessageMapper())); messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>(); _connection = new Connection(name: new ConnectionName("test"), dataType: typeof(MyEvent), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: "fakekey"); _newConnection = new Connection(name: new ConnectionName("newTest"), dataType: typeof(MyEvent), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: "fakekey"); _dispatcher = new Dispatcher(_commandProcessor, messageMapperRegistry, new List <Connection> { _connection }); var @event = new MyEvent(); var message = new MyEventMessageMapper().MapToMessage(@event); _channel.Add(message); Assert.AreEqual(DispatcherState.DS_AWAITING, _dispatcher.State); _dispatcher.Receive(); }
public DispatcherAddNewConnectionTests() { _channel = new FakeChannel(); _commandProcessor = new SpyCommandProcessor(); var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyEventMessageMapper())); messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>(); _subscription = new Subscription <MyEvent>(new SubscriptionName("test"), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey")); _newSubscription = new Subscription <MyEvent>(new SubscriptionName("newTest"), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey")); _dispatcher = new Dispatcher(_commandProcessor, messageMapperRegistry, new List <Subscription> { _subscription }); var @event = new MyEvent(); var message = new MyEventMessageMapper().MapToMessage(@event); _channel.Enqueue(message); _dispatcher.State.Should().Be(DispatcherState.DS_AWAITING); _dispatcher.Receive(); }
private void UpdateEvent() { int n = events.Count; for (int i = 0; i < n; i++) { MyEvent e = events[i]; AnimatorStateInfo infos = (AnimatorStateInfo)this.GetStateInfo(); if (Mathf.Abs(infos.normalizedTime - e.time) < 0.08 && infos.IsName(e.state)) { if (e.callback()) { events.RemoveAt(i); n--; } else { i++; } } } }
public async void Can_Publish_Event_To_EventGrid() { //arrange _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _httpClient.DefaultRequestHeaders.Add("aeg-sas-key", TopicSettings.Key); _pause = new ManualResetEvent(false); _queueClient = new QueueClient(ProxySettings.StorageAccountConnectionString, ProxySettings.QueueName); _queueClient.CreateIfNotExists(); _queueClient.ClearMessages(); var myEvent = new MyEvent() { Type = "TestEvent", Version = "V1.0", CorrelationId = Guid.NewGuid().ToString() }; //act var result = await PublishEventAsync(myEvent); //assert Assert.True(result.IsSuccessStatusCode); PollStorageQueueUntilEventArrives(); QueueMessage[] messages = _queueClient.ReceiveMessages(); var firstMessageJson = Encoding.UTF8.GetString(Convert.FromBase64String(messages.First().MessageText)); var cloudEvent = JsonConvert.DeserializeObject <CloudEvent <MyEvent> >(firstMessageJson); Assert.Equal(cloudEvent.Data.Type, myEvent.Type); Assert.Equal(cloudEvent.Data.Version, myEvent.Version); Assert.Equal(cloudEvent.Data.CorrelationId, myEvent.CorrelationId); }
public MessageDispatcherMultipleConnectionTests() { _eventChannel = new FakeChannel(); _commandChannel = new FakeChannel(); var commandProcessor = new SpyCommandProcessor(); var container = new ServiceCollection(); container.AddTransient <MyEventMessageMapper>(); container.AddTransient <MyCommandMessageMapper>(); var messageMapperRegistry = new MessageMapperRegistry(new ServiceProviderMapperFactory(container.BuildServiceProvider())); messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>(); messageMapperRegistry.Register <MyCommand, MyCommandMessageMapper>(); var myEventConnection = new Subscription <MyEvent>(new SubscriptionName("test"), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_eventChannel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey")); var myCommandConnection = new Subscription <MyCommand>(new SubscriptionName("anothertest"), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_commandChannel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey")); _dispatcher = new Dispatcher(commandProcessor, messageMapperRegistry, new List <Subscription> { myEventConnection, myCommandConnection }); var @event = new MyEvent(); var eventMessage = new MyEventMessageMapper().MapToMessage(@event); _eventChannel.Enqueue(eventMessage); var command = new MyCommand(); var commandMessage = new MyCommandMessageMapper().MapToMessage(command); _commandChannel.Enqueue(commandMessage); _dispatcher.State.Should().Be(DispatcherState.DS_AWAITING); _dispatcher.Receive(); }
private void TryAssertionWithRefTime(EPServiceProvider epService, string epl) { string[] fields = "id".Split(','); EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(MyEvent.MakeTime("E1", "8:00:00.000")); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E2", "8:00:04.999")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E3", "8:00:05.000")); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" } }, null); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E4", "8:00:04.000")); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E5", "7:00:00.000")); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E6", "8:01:04.999")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E7", "8:01:05.000")); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), fields, new object[][] { new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } }, new object[][] { new object[] { "E1" }, new object[] { "E2" } }); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E8", "8:03:55.000")); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), fields, new object[][] { new object[] { "E7" } }, new object[][] { new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } }); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E9", "0:00:00.000")); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E10", "8:04:04.999")); epService.EPRuntime.SendEvent(MyEvent.MakeTime("E11", "8:04:05.000")); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), fields, new object[][] { new object[] { "E8" }, new object[] { "E9" }, new object[] { "E10" } }, new object[][] { new object[] { "E7" } }); stmt.Dispose(); }
public async Task Should_append_events_and_publish() { var commitId = Guid.NewGuid(); var event1 = new MyEvent(); var event2 = new MyEvent(); var eventData1 = new EventData(); var eventData2 = new EventData(); eventDataFormatter.Setup(x => x.ToEventData(It.Is <Envelope <IEvent> >(e => e.Payload == event1), commitId)).Returns(eventData1); eventDataFormatter.Setup(x => x.ToEventData(It.Is <Envelope <IEvent> >(e => e.Payload == event2), commitId)).Returns(eventData2); eventStore.Setup(x => x.AppendEventsAsync(commitId, streamName, 123, It.Is <IEnumerable <EventData> >(e => e.Count() == 2))) .Returns(TaskHelper.Done) .Verifiable(); domainObject.AddEvent(event1); domainObject.AddEvent(event2); await sut.SaveAsync(domainObject, domainObject.GetUncomittedEvents(), commitId); eventStore.VerifyAll(); }
public bool updateEvent(MyEvent myEvent) { bool success = false; query = @"UPDATE event SET Campus = @Campus, DatePosted = @DatePosted, Description = @Description, EntryFee = @EntryFee, Image = @Image, Location = @Location, Name = @Name, University = @University WHERE Id = @Id AND EventPosterId = @EventPosterId"; using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString()))) { //General command.Parameters.AddWithValue("@Id", myEvent.Id); command.Parameters.AddWithValue("@EventPosterId", myEvent.EventPosterId); command.Parameters.AddWithValue("@Campus", myEvent.Campus); command.Parameters.AddWithValue("@Date", myEvent.Date); command.Parameters.AddWithValue("@DatePosted", myEvent.DatePosted); command.Parameters.AddWithValue("@Description", myEvent.Description); command.Parameters.AddWithValue("@EntryFee", myEvent.EntryFee); command.Parameters.AddWithValue("@Image", myEvent.Image); command.Parameters.AddWithValue("@Location", myEvent.Location); command.Parameters.AddWithValue("@Name", myEvent.Name); command.Parameters.AddWithValue("@University", myEvent.University); command.Connection.Open(); command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); command.Connection.Close(); success = true; } return(success); }
public MessageDispatcherResetConnection() { _channel = new FakeChannel(); _commandProcessor = new SpyCommandProcessor(); var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory(() => new MyEventMessageMapper())); messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>(); _connection = new Connection <MyEvent>(new ConnectionName("test"), noOfPerformers: 1, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey")); _dispatcher = new Dispatcher(_commandProcessor, messageMapperRegistry, new List <Connection> { _connection }); var @event = new MyEvent(); var message = new MyEventMessageMapper().MapToMessage(@event); _channel.Add(message); _dispatcher.State.Should().Be(DispatcherState.DS_AWAITING); _dispatcher.Receive(); Task.Delay(1000).Wait(); _dispatcher.Shut(_connection); }
//public delegate void MyEventAction(string someParameter); //public event MyEventAction MyEvent; //// rise event when you need to //MyEvent?.Invoke("123"); //public async void SafeLocation() //{ //} public async void SearchLocation() { //Search Location try { var address = this.locationtxt + " Puerto Rico"; //Get Country from user address database var locations = await Geocoding.GetLocationsAsync(address); var location = locations?.FirstOrDefault(); //test //geoCoder = new Geocoder(); //var fortMasonPosition = new Position(location.Latitude, location.Longitude); //var possibleAddresses = await geoCoder.GetAddressesForPositionAsync(fortMasonPosition); //var placetest = possibleAddresses?.FirstOrDefault(); //await Application.Current.MainPage.DisplayAlert("Test", placetest, "Ok"); //return; if (location != null) { // Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}"); this.Loc = location; MyEvent?.Invoke(this.Locationtxt); // el parametro es innecesario luego se elimina //await LoadSearchPin(); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Handle exception that may have occurred in geocoding } }
private void OnCollect(MyEvent obj) { //UnityIOSMsg.removeListioner(IOSEvent.Collect, OnCollect); IOSEvent e = obj as IOSEvent; MsgFromIOS.InfoFromIOS info = (MsgFromIOS.InfoFromIOS)e.data; //if (info.result == "0") //{ // return; //} switch (info.CollectType) { case "0": selectToggle.isOn = false; break; case "1": selectToggle.isOn = true; break; default: break; } }
private void ShootDir(MyEvent evt) { Log.Sys("ShootDir: " + evt.vec2); if (this != null) { if (!autoCheck.IsDead) { //Vector3 lastDir; var conDir = new Vector3(evt.vec2.x, 0, evt.vec2.y); //controlDir = conDir; if (conDir.sqrMagnitude <= 0.1f) { return; } conDir.Normalize(); controlDir = Quaternion.FromToRotation(Vector3.forward, conDir).eulerAngles.y; if (sector.IsHitTarget && sector.hitTarget != null) { var targetDir = sector.hitTarget.transform.position - transform.position; targetDir.y = 0; targetDir.Normalize(); //transform.parent.forward = targetDir; //lastDir = targetDir; lastDir = ((targetDir + conDir)).normalized; //lastDir = conDir; } else { //transform.parent.forward = conDir; lastDir = conDir; } transform.forward = conDir; } } }
/// <summary> /// Start listening specified event. /// </summary> /// <param name="eventName">Event name.</param> /// <param name="listener">Listener.</param> public static void StartListening(string eventName, UnityAction <GameObject, string> listener) { if (instance == null) { instance = FindObjectOfType(typeof(EventManager)) as EventManager; if (instance == null) { Debug.Log("Have no event manager on scene"); return; } } MyEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new MyEvent(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }
IEnumerator Scene15() { yield return(dailyData11.DouZi.walkTo(16)); PerformSystem.FadeOut(dailyData11.DouZi.gameObject); PerformSystem.FadeOut(dailyData11.Bowl); while (true) { yield return(new WaitForSeconds(15)); string words = ""; switch ((int)Random.Range(0, 5)) { case 0: words = "变喽……时代变喽……"; break; case 1: words = "新鲜事物多喽……老头子都跟不上喽……"; break; case 2: words = "还是以前的日子舒服唷……"; break; case 3: words = "闲无事在敌楼我亮一亮琴音,我面前缺少个知音的人 ——"; break; case 4: words = "就剩这间戏院喽……"; break; } yield return(MyEvent.Speak(dailyData11.LaoHu, words, 5)); } }
public async Task Should_throw_exception_if_final_version_does_not_match_to_expected() { var eventData1 = new EventData(); var eventData2 = new EventData(); var event1 = new MyEvent(); var event2 = new MyEvent(); var events = new List <StoredEvent> { new StoredEvent("0", 0, eventData1), new StoredEvent("1", 1, eventData2) }; A.CallTo(() => eventStore.GetEventsAsync(streamName)) .Returns(events); A.CallTo(() => formatter.Parse(eventData1, true)) .Returns(new Envelope <IEvent>(event1)); A.CallTo(() => formatter.Parse(eventData2, true)) .Returns(new Envelope <IEvent>(event2)); await Assert.ThrowsAsync <DomainObjectVersionException>(() => sut.LoadAsync(domainObject, 200)); }
// asynchronous waiting for a specified message by a single method call, without need to Subscribe/Unsubscribe to this message public static async Task WhenExample() { var hub = new MetaPubSub(); // publishing a MyEvent with 500 ms delay var t = Task.Run(async() => { await Task.Delay(500); await hub.Publish(new MyEvent()); }); try { // This method will wait for MyEvent one second. // If the event will not arrive in a specified timeout the TimeoutException will be thrown. MyEvent res = await hub.When <MyEvent>(millisecondsTimeout : 1000); Console.WriteLine($"Received MyEvent at {DateTime.Now:HH:mm:ss.fff}"); } catch (TimeoutException ex) { Console.WriteLine($"Exception {ex.GetType()}: {ex.Message}"); } }
public static void CriarEvento(string nome, UnityAction <GameObject, string> evento) { if (instancia == null) { instancia = FindObjectOfType(typeof(EventManager)) as EventManager; if (instancia == null) { Debug.Log("There is no EventManager"); return; } } MyEvent esteEvento = null; if (instancia.eventos.TryGetValue(nome, out esteEvento)) { esteEvento.AddListener(evento); } else { esteEvento = new MyEvent(); esteEvento.AddListener(evento); instancia.eventos.Add(nome, esteEvento); } }
public static void broadcast(ref MyEvent <T1> p_event, ref T1 p_param1) { p_event.IsBroadcasting = true; var l_eventInterator = p_event.Callbacks.GetRefEnumerator(); while (l_eventInterator.MoveNext()) { if (l_eventInterator.GetCurrentRef().value.Execute(ref p_param1) == EventCallbackResponse.REMOVE) { if (p_event.RemoveQueue == null) { p_event.RemoveQueue = new List <int>(); } p_event.RemoveQueue.Add(l_eventInterator.GetCurrentRef().value.Handle); } } p_event.IsBroadcasting = false; if (p_event.RemoveQueue != null && p_event.RemoveQueue.Count > 0) { for (int i = 0; i < p_event.RemoveQueue.Count; i++) { unRegister(ref p_event, p_event.RemoveQueue[i]); } p_event.RemoveQueue.Clear(); } if (p_event.AddedCallbackQueue != null && p_event.AddedCallbackQueue.Count > 0) { for (int i = 0; i < p_event.AddedCallbackQueue.Count; i++) { ref IEventCallback l_callback = ref p_event.AddedCallbackQueue.ValueRef(i); p_event.Callbacks[l_callback.Handle] = l_callback; } p_event.AddedCallbackQueue.Clear(); }
public MessagePumpRetryEventConnectionFailureTests() { _commandProcessor = new SpyCommandProcessor(); _channel = new FailingChannel { NumberOfRetries = 4 }; var mapper = new MyEventMessageMapper(); _messagePump = new MessagePump <MyEvent>(_commandProcessor, mapper) { Channel = _channel, TimeoutInMilliseconds = 5000, RequeueCount = -1 }; _event = new MyEvent(); var message1 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(_event))); var message2 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(_event))); _channel.Enqueue(message1); _channel.Enqueue(message2); var quitMessage = new Message(new MessageHeader(Guid.Empty, "", MessageType.MT_QUIT), new MessageBody("")); _channel.Enqueue(quitMessage); }
public List <MyEvent> Convert(string json) { JArray eventsArr = JArray.Parse(json); List <MyEvent> myEvents = new List <MyEvent>(); foreach (var eventDetail in eventsArr.Children()) { var myEvent = new MyEvent(); myEvent.eventType = MyEvent.ConvertEventType((string)eventDetail["eventType"]); myEvent.timeStamp = (DateTime)eventDetail["timeStamp"]; myEvent.flight = (string)eventDetail["flight"]; myEvent.passengers = (int)eventDetail["passengers"]; if (myEvent.eventType.Equals(EventType.Arrival)) { myEvent.delayed = (TimeSpan)eventDetail["delayed"]; } if (myEvent.eventType.Equals(EventType.Departure)) { myEvent.destination = (string)eventDetail["destination"]; } myEvents.Add(myEvent); } return(myEvents); }
public async Task Should_ignore_exception_when_saving() { A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .Ignored)) .Throws(new InvalidOperationException()); await sut.ActivateAsync(id, store); var event1 = new MyEvent(); var event2 = new MyEvent(); var newState = new MyDomainState(); sut.RaiseEvent(event1); sut.RaiseEvent(event2); sut.UpdateState(newState); await sut.WriteAsync(A.Fake <ISemanticLog>()); A.CallTo(() => persistence.WriteSnapshotAsync(newState)) .MustHaveHappened(); A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .That.Matches(x => x.Count() == 2))) .MustHaveHappened(); Assert.Empty(sut.GetUncomittedEvents()); }
public Task Handle(MyEvent message, IMessageHandlerContext context) { return(Task.FromResult(0)); }
void NotExecuted() { explosionTriggered = null; }
public void SomeAction() { MyEvent?.Invoke(1, 2); }
public void add_XX (MyEvent e) { return; }
protected virtual void RaiseMyevent() => MyEvent?.Invoke(this, EventArgs.Empty);
private void RunAssertionWithRefTime(String epl) { String[] fields = "id".Split(','); EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.Events += _listener.Update; _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E1", "08:00:00.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E2", "08:00:04.999")); Assert.IsFalse(_listener.IsInvoked); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E3", "08:00:05.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" } }, null); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E4", "08:00:04.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E5", "07:00:00.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E6", "08:01:04.999")); Assert.IsFalse(_listener.IsInvoked); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E7", "08:01:05.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E3" }, new Object[] { "E4" }, new Object[] { "E5" }, new Object[] { "E6" } }, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" } }); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E8", "08:03:55.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E7" } }, new Object[][] { new Object[] { "E3" }, new Object[] { "E4" }, new Object[] { "E5" }, new Object[] { "E6" } }); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E9", "00:00:00.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E10", "08:04:04.999")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E11", "08:04:05.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E8" }, new Object[] { "E9" }, new Object[] { "E10" } }, new Object[][] { new Object[] { "E7" } }); stmt.Dispose(); }
public void TestExtBatchedNoReference() { String[] fields = "id".Split(','); EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select irstream * from MyEvent.win:ext_timed_batch(mytimestamp, 1 minute)"); stmt.Events += _listener.Update; _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E1", "08:00:00.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E2", "08:00:30.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E3", "08:00:59.999")); Assert.IsFalse(_listener.IsInvoked); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E4", "08:01:00.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" }, new Object[] { "E3" } }, null); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E5", "08:01:02.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E6", "08:01:05.000")); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E7", "08:02:00.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E4" }, new Object[] { "E5" }, new Object[] { "E6" } }, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" }, new Object[] { "E3" } }); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E8", "08:03:59.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E7" } }, new Object[][] { new Object[] { "E4" }, new Object[] { "E5" }, new Object[] { "E6" } }); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E9", "08:03:59.000")); Assert.IsFalse(_listener.IsInvoked); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E10", "08:04:00.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E8" }, new Object[] { "E9" } }, new Object[][] { new Object[] { "E7" } }); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E11", "08:06:30.000")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E10" } }, new Object[][] { new Object[] { "E8" }, new Object[] { "E9" } }); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E12", "08:06:59.999")); Assert.IsFalse(_listener.IsInvoked); _epService.EPRuntime.SendEvent(MyEvent.MakeTime("E13", "08:07:00.001")); EPAssertionUtil.AssertPropsPerRow( _listener.AssertInvokedAndReset(), fields, new Object[][] { new Object[] { "E11" }, new Object[] { "E12" } }, new Object[][] { new Object[] { "E10" } }); }
private void Update() { if (!CanProcessEvent) { return; } if (state == RightState.Idle) { if (WindowMng.windowMng.IsOtherUIOpen()) { return; } #if UNITY_EDITOR || UNITY_STANDALONE if (Input.GetMouseButtonDown(0)) { var mousePos = Input.mousePosition; if (mousePos.x > Screen.width / 2) { state = RightState.Move; rb.EnterMove(); rf.EnterMove(); useMouse = true; rb.SetFingerPos(mousePos); rf.SetFingerPos(mousePos); CalculateShootDir(); //MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot); enterTime = Time.time; } } else #endif { foreach (var touch in Input.touches) { fingerId = touch.fingerId; //if (fingerId > 0 && fingerId < Input.touchCount) if (touch.phase == TouchPhase.Began) { if (Input.GetTouch(fingerId).position.x > Screen.width / 2) { state = RightState.Move; var fp = Input.GetTouch(fingerId).position; rb.EnterMove(); rf.EnterMove(); useMouse = false; rb.SetFingerPos(fp); rf.SetFingerPos(fp); CalculateShootDir(); //MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot); enterTime = Time.time; break; } } } } } else { if (Time.time - enterTime > 0.0f && enterTime != 0) { MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot); enterTime = 0; } if (WindowMng.windowMng.IsOtherUIOpen()) { state = RightState.Idle; rb.ExitMove(); rf.ExitMove(); useMouse = false; MyEventSystem.PushEventStatic(MyEvent.EventType.ExitShoot); return; } #if UNITY_EDITOR || UNITY_STANDALONE if (useMouse) { if (!Input.GetMouseButton(0)) { state = RightState.Idle; rb.ExitMove(); rf.ExitMove(); useMouse = false; var exit = new MyEvent() { type = MyEvent.EventType.ExitShoot, boolArg = !rb.IsCancel(), }; MyEventSystem.myEventSystem.PushEvent(exit); /* * if (!rb.IsCancel()) * { * //MyEventSystem.PushEventStatic (MyEvent.EventType.Shoot); * GameInterface.gameInterface.PlayerAttack(); * } */ } else { var mousePos = Input.mousePosition; rb.SetFingerPos(mousePos); rf.SetFingerPos(mousePos); CalculateShootDir(); } } else #endif { var find = false; Touch touch = new Touch(); var getTouch = false; foreach (var t in Input.touches) { if (t.fingerId == fingerId) { touch = t; getTouch = true; break; } } if (getTouch) { var phase = touch.phase; find = phase == TouchPhase.Ended || phase == TouchPhase.Canceled; } else { find = true; } if (find) { state = RightState.Idle; rb.ExitMove(); rf.ExitMove(); var exit = new MyEvent() { type = MyEvent.EventType.ExitShoot, boolArg = !rb.IsCancel(), }; MyEventSystem.myEventSystem.PushEvent(exit); /* * if (!rb.IsCancel()) * { * GameInterface.gameInterface.PlayerAttack(); * } */ } else { var pos = touch.position; rb.SetFingerPos(pos); rf.SetFingerPos(pos); CalculateShootDir(); } } } }
// apply the event private void Handle(MyEvent e) { }
public void ActionDelegate() { MyEvent.ActionDelegate(); }
public void RaiseEvent(string message) { MyEvent?.Invoke(message); }
private bool Equals(MyEvent other) { return this.Identifier == other.Identifier; }
protected void B(object o, MyEvent e) { }