static void Main(string[] args) { XmlConfigurator.Configure(); IApiPushServiceConfiguration configuration = new ApiPushServiceConfiguration(); ISubscriptionStorage subscriptionStorage = new ReadonlyJsonSubscriptionStorage(); IPushSender pushSender = new PushSender(); Consumer consumer = new Consumer(subscriptionStorage, pushSender, configuration); IAutoSubscriberMessageDispatcher dispatcher = new MessageDispatcher(consumer); HostFactory.Run(x => { x.Service<ApiPushService>(s => { s.ConstructUsing(() => new ApiPushService(configuration, dispatcher)); s.WhenStarted(push => push.Start()); s.WhenStopped(push => push.Stop()); }); x.RunAsLocalSystem(); x.SetDescription("Service that consumes events over rabbitMQ and pushes notifications to http endpoints"); x.SetDisplayName("ApiPush"); x.SetServiceName("ApiPush"); }); }
public static MessageDispatcher Instance() { if (self == null) self = new MessageDispatcher(); return self; }
static void Main(string[] args) { // Set working directory to application directory. // Otherwise Windows/System32 is used. Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; try { XmlConfigurator.Configure(); Console.WriteLine("Loaded app.config"); } catch (Exception) { Console.WriteLine("Error: configuration file not found."); throw; } try { MessageDispatcher md = new MessageDispatcher(); md.RegisterHandlers(new Program()); ClientListener server = new ClientListener(3333, new SocketListener(), md); server.Start(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static MessageDispatcher Instance() { if (instance == null) { instance = new MessageDispatcher (); } return instance; }
public void Setup() { _apiPushServiceConfiguration = Substitute.For<IApiPushServiceConfiguration>(); _pushSender = Substitute.For<IPushSender>(); _subscriptionStorage = Substitute.For<ISubscriptionStorage>(); Consumer consumer = new Consumer(_subscriptionStorage, _pushSender, _apiPushServiceConfiguration); dispatcher = new MessageDispatcher(consumer); }
public async void MissingMethodReturnsError() { var dispatcher = new MessageDispatcher(); var request = new JObject( new JProperty("id", "ID"), new JProperty("method", "NonExistentMethod")); var response = await dispatcher.DispatchAsync(request); Assert.Equal(-32601, (int)response["error"]["code"]); }
public void SampleMessageFieldParams() { var defaultSerializer = new DefaultSerializer<SampleMessage>(this.messageRegistry, this.typeRegistry); var d = new MessageDispatcher<SampleApiClass>(this.messageRegistry, this.typeRegistry); using (var buf = new ThreadSafeWriteQueue(1024)) { var orig = new SampleMessage { MessageId = defaultSerializer.MessageId, A = 10 }; defaultSerializer.Serialize(buf, orig); var pos = buf.ReadMessage(); Assert.IsTrue(d.Dispatch(buf, pos, defaultSerializer.MessageId, new SampleApiClass())); } }
public static void Setup() { Dispatcher = new MessageDispatcher(new InMemoryEventStore()); Dispatcher.ScanInstance(new TabCommandHandlers()); OpenTabQueries = new OpenTabs(); Dispatcher.ScanInstance(OpenTabQueries); ChefTodoListQueries = new ChefTodoList(); Dispatcher.ScanInstance(ChefTodoListQueries); }
public void Dispatch_invokes_the_correct_handler() { var messageHandler = new Mock<IMessageHandler<string>>(); var kernel = new StandardKernel(); kernel .Bind<IMessageHandler<string>>() .ToConstant(messageHandler.Object); var msg = "test message"; var msgDispatcher = new MessageDispatcher(kernel); msgDispatcher.Dispatch<string>(msg); messageHandler.Verify(x => x.Handle(msg), Times.Once()); }
public async void ReturnsResultFromCallback() { var dispatcher = new MessageDispatcher(); dispatcher.RegisterMethod("testMethod", (@params) => { return Task.FromResult<object>("result"); }); var request = new JObject( new JProperty("id", "ID"), new JProperty("method", "testMethod")); var response = await dispatcher.DispatchAsync(request); Assert.Equal("result", (string)response["result"]); }
public async void DispatchesRequest() { var dispatcher = new MessageDispatcher(); var called = false; dispatcher.RegisterMethod("testMethod", (requestMessage) => { called = true; return Task.FromResult<object>(1); }); var request = new JObject( new JProperty("id", "ID"), new JProperty("method", "testMethod")); var response = await dispatcher.DispatchAsync(request); Assert.True(called); }
public static void Setup() { var eventStorage = new CloudTableStore(); Dispatcher = new MessageDispatcher(eventStorage); Dispatcher.ScanInstance(new TabCommandHandlers()); OpenTabQueries = new OpenTabs(); Dispatcher.ScanInstance(OpenTabQueries); ChefTodoListQueries = new ChefTodoList(); Dispatcher.ScanInstance(ChefTodoListQueries); var aggregates = eventStorage.GetAllAggregates(); foreach (var agg in aggregates) Dispatcher.GetType().GetMethod("ReplayEvents") .MakeGenericMethod(agg.Item1) .Invoke(Dispatcher, new object[] { agg.Item2 }); }
public static void TeachingLadies(MessageDispatcher dispatcher) { var scheduleId = new Guid("8573961f-f203-4e39-b6a8-2d9de9f82534"); var division = "Teaching Ladies"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("ba35ffcb-0a1e-4ac7-9b37-6e8278099cfc"), division, 01, "MB", "NO", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("d65587d6-e17a-47d2-ad98-6cb2dc146a34"), division, 01, "SK", "AB", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("0dabc7b9-588b-41d3-a2e6-32af5c8ad7ef"), division, 01, "BC", "SO", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("adc53323-c123-4162-90fd-c2fcd6987a36"), division, 01, "QC", "NL", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("44b256a5-71bd-43d1-b24a-6e379bdfbba8"), division, 02, "BC", "QC", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("2a4649d5-edf8-4b82-bb64-ee9992ded5cc"), division, 02, "SO", "NL", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("77cba391-83a1-4ced-b772-2d90f048c70c"), division, 02, "AB", "MB", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("08d0c40c-8089-491f-945c-a9fba3e66fda"), division, 02, "NO", "SK", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("afd76742-f583-4fcf-997d-c6aaed58ec63"), division, 03, "SO", "SK", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("3ad2acbd-b9bf-4721-8085-a264443c757c"), division, 03, "QC", "MB", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("ef76b1bf-c69c-4751-a02f-89b8d5878ec2"), division, 03, "NL", "NO", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("1cc43434-5c78-4c74-8939-b23e9f184119"), division, 03, "AB", "BC", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("5e68eef3-8315-4179-8b8d-ecc117119c38"), division, 04, "NL", "AB", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("583efdec-88db-4777-97b8-563c8d4d66a8"), division, 04, "NO", "BC", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("a10bd7f1-240c-46f1-a8e1-43e763de5ba4"), division, 04, "SK", "QC", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("1f8f4ac7-2c27-408c-bf4e-8ac7eeac4e9f"), division, 04, "MB", "SO", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("a775eeaf-bb2d-4074-8f54-ec49e1ab7cea"), division, 05, "QC", "NO", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("b0fe3b6c-bba6-43cf-9a59-49fbff568834"), division, 05, "AB", "SO", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("df324190-7d40-4e58-bc4b-2a40a7d02f9c"), division, 05, "MB", "NL", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("62a8f201-db91-42cd-bd28-a75bc9dbb3f0"), division, 05, "BC", "SK", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("c2584bf7-7252-4587-be58-e1db503fcfa4"), division, 06, "NL", "BC", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("4cd01041-3754-4aed-9a7f-02976187094c"), division, 06, "SK", "MB", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("e0ffdde7-2164-4707-bd88-0a4ef81c75fb"), division, 06, "SO", "QC", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("49308d38-1563-420a-8209-ba0f312ab4c6"), division, 06, "NO", "AB", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("fdcc4304-9066-416c-8462-0a8fc27ce064"), division, 07, "NO", "SO", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("cb85279c-53ea-40af-a07e-ff92c2b66f05"), division, 07, "QC", "AB", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("8a3b543c-5368-487a-80f8-07324ddb9425"), division, 07, "NL", "SK", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("a57eb097-3cae-4e11-94e2-f1f4a538c3c1"), division, 07, "MB", "BC", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("fd4a5efd-6b83-40c8-a017-61c9c4d7c14c"), division, 08, "SO", "MB", 03, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("b5c18a8c-744e-4051-a698-cd112c5f1425"), division, 08, "QC", "SK", 05, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("9c0b0919-514d-4e89-a95e-325c17ec5aa3"), division, 08, "BC", "NO", 07, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("db0169ae-7ef1-4e09-a74a-01bed4651554"), division, 08, "AB", "NL", 09, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("df01483a-699f-496c-9018-f6f939506fad"), division, 09, "BC", "NL", 03, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("b303a63c-5036-41ec-adb2-9367a68c3846"), division, 09, "AB", "NO", 05, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("8c0de229-4697-40fe-9f79-4476cdfb35f9"), division, 09, "MB", "SK", 07, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("7c504342-701b-46d4-8e25-e11b55dee546"), division, 09, "QC", "SO", 09, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("72e79259-640b-4251-a4af-04e4f4f4d40a"), division, 10, "NO", "QC", 03, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("cf1a0059-0f54-473e-a5d3-fb0387e2790f"), division, 10, "NL", "MB", 05, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("504efb2d-7d6f-4725-9cbf-6055c2d6d79e"), division, 10, "SO", "AB", 07, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("c5d8430a-5e8f-44be-a503-925f11bb69b9"), division, 10, "SK", "BC", 09, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("06916fee-be82-40d9-b5bd-8fde7b46d2d2"), division, 11, "AB", "SK", 03, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("116d1944-61c6-4393-8e03-92647cf00414"), division, 11, "SO", "BC", 05, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("086ccf3f-f8e1-46ed-bd30-63e1a2986be2"), division, 11, "NL", "QC", 07, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("302d01ab-daeb-4f20-b51a-b71860acd613"), division, 11, "NO", "MB", 09, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("5fda8fbf-4c89-4c7c-b1dd-2e56f6ebcb1f"), division, 12, "NL", "SO", 11, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("c856b6b9-9fec-41be-826d-64e2b7aefe81"), division, 12, "SK", "NO", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("667f36f1-2ebb-42ef-be5a-63c38428107b"), division, 12, "QC", "BC", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("f826f0db-726b-452c-97ec-787588bdb88b"), division, 12, "MB", "AB", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("ed9f12fe-2ced-4d45-bbf0-1148712f1fd5"), division, 13, "AB", "QC", 11, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("81f37da8-2f3e-480b-a4e3-78f7b43f1dc0"), division, 13, "SO", "NO", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("1b1014b4-a4fa-4f6b-9641-657414c7a0bf"), division, 13, "BC", "MB", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("a1c0c3e9-5972-4f84-b37c-d32b6ec8b471"), division, 13, "SK", "NL", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("bb638807-cd28-4ee8-9246-f0109a1b6aec"), division, 14, "BC", "AB", 03, BowlingCentre.Academy, true), new SaveMatch(new Guid("c43670c2-ead4-4137-a402-e9bf947c90cc"), division, 14, "NO", "NL", 05, BowlingCentre.Academy, true), new SaveMatch(new Guid("09ee005f-5bb8-48c7-a4f3-a50839303b49"), division, 14, "MB", "QC", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("6334b7e3-2b44-4f06-81dc-9dfb86501310"), division, 14, "SK", "SO", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("67dc9db6-a539-44e5-854a-a48804d3692d"), division, 15, "NO", "SK", 03, BowlingCentre.Academy, true), new SaveMatch(new Guid("668917d7-9301-4cce-ab3d-38b6f39c9686"), division, 15, "AB", "MB", 07, BowlingCentre.Academy, true), new SaveMatch(new Guid("5b2ba535-b0ff-4264-a893-1e6d94a77ce0"), division, 15, "SO", "NL", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("a172cc10-a62b-4f7d-be2d-8f88bdd8ae57"), division, 15, "BC", "QC", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("f35b10ee-29e6-4644-9a02-e8c0abdd4061"), division, 16, "QC", "NL", 03, BowlingCentre.Academy, true), new SaveMatch(new Guid("f7cc6580-fbf9-465e-beac-86880b824aca"), division, 16, "BC", "SO", 05, BowlingCentre.Academy, true), new SaveMatch(new Guid("be9f5745-a9f0-447c-a28c-d1d27e0867e8"), division, 16, "SK", "AB", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("e4dc2601-248d-479c-a8b2-66b8bc977422"), division, 16, "MB", "NO", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("8372a493-6a37-44c7-a8b9-db9d9153d0fe"), division, 17, "SO", "MB", 03, BowlingCentre.Academy, true), new SaveMatch(new Guid("f5e2f9c5-fcd1-4295-a714-2083006faed9"), division, 17, "NO", "BC", 07, BowlingCentre.Academy, true), new SaveMatch(new Guid("96b961f5-5994-41d1-a096-62cab65ae1ad"), division, 17, "SK", "QC", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("71f007c0-b0b0-48c9-a5e5-a82fababbaa2"), division, 17, "NL", "AB", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("ef260b19-d868-4132-b95d-e530751721ba"), division, 18, "QC", "AB", 05, BowlingCentre.Academy, true), new SaveMatch(new Guid("e9b8423b-5f16-421d-b78f-1527f1818445"), division, 18, "NL", "SK", 07, BowlingCentre.Academy, true), new SaveMatch(new Guid("606b3063-ffbf-437f-964a-1cf1b305038e"), division, 18, "NO", "SO", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("6c7d70bd-7c1a-4b2f-99e5-50978e1c8d3b"), division, 18, "MB", "BC", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("886aadd9-1896-4111-8cb3-a48e2eb64f4a"), division, 19, "NO", "AB", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("8cd5fd29-fb6a-4a66-955f-66ca19537d62"), division, 19, "SO", "QC", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("a11c4e37-3af9-41e3-966a-48d45e0d45b8"), division, 19, "SK", "MB", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("da5a9fe2-b69b-4fdc-8a9d-93d2f365e495"), division, 19, "NL", "BC", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("881f837d-ca32-41f5-9f7f-4c54c981a8f7"), division, 20, "QC", "MB", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("33476778-b3f9-498d-a81f-449e868cd425"), division, 20, "AB", "BC", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("ee5ec77c-6e4b-46b7-aeb4-26c83bc85683"), division, 20, "NL", "NO", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("bcb5320e-02ba-4599-87d3-a8a89c0d281c"), division, 20, "SK", "SO", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("cf03f4ef-c832-4048-9538-76272700474e"), division, 21, "BC", "SK", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("ba30d979-818e-4031-b1a6-0371bbbd951c"), division, 21, "MB", "NL", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("945c0213-5bff-45d7-bce3-39375088fb77"), division, 21, "AB", "SO", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("e945c02f-0a92-4b3c-bacf-6d70b394094e"), division, 21, "QC", "NO", 19, BowlingCentre.Rossmere, true), }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
public static void Seniors(MessageDispatcher dispatcher) { var scheduleId = new Guid("934315dd-f51d-4ee5-b53b-a7cefde960d0"); var division = "Seniors"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("f189e07b-8492-43b1-9f39-96a357800418"), division, 01, "BC", "SK", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("a92009cf-fb7e-4497-a37d-1fa6ce6341d1"), division, 01, "NO", "AB", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("f12183be-f591-46d8-a03f-f091f023d5c1"), division, 01, "QC", "SO", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("98ada3ae-1e85-4cdc-b89f-c8f0a06b5403"), division, 01, "NL", "MB", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("906be187-e639-414d-a28b-8f204018ccf9"), division, 02, "QC", "NL", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("22847ae0-e2ab-40dd-be7c-7b3c376e2bd4"), division, 02, "SO", "MB", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("452c3363-4054-449a-8dc1-61b51ac1cf2f"), division, 02, "AB", "BC", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("ed7506a9-7499-4cad-96d0-a28203c26158"), division, 02, "SK", "NO", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("a45e27e2-07f1-459f-9c32-e2d51e072fd9"), division, 03, "SO", "NO", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("ce38cf3c-d5b4-4842-a054-e632a3ace6cf"), division, 03, "NL", "BC", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("d9bd8145-de6b-482a-b5e9-631d398a3cc6"), division, 03, "MB", "SK", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("72703047-b250-4ad6-a455-e218ee5aad36"), division, 03, "AB", "QC", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("d831cacb-5c28-426b-829a-b0c865331737"), division, 04, "MB", "AB", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("ab6e196c-74cf-4e9b-a71e-68321135b739"), division, 04, "SK", "QC", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("fad4ca09-158a-4451-ad43-23fbb710d096"), division, 04, "NO", "NL", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("21bb3fab-391b-4792-9a74-4b70904cefff"), division, 04, "BC", "SO", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("d7699a57-09b9-42ea-b00b-ada02c1ca7e1"), division, 05, "NL", "SK", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("77c76147-1dc5-402a-8dbe-8100a2ae4cc0"), division, 05, "AB", "SO", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("bef619ac-6e85-413b-9ac1-94be6d6adbae"), division, 05, "BC", "MB", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("17061c1e-f377-41a8-9168-cc70bdf1d3b9"), division, 05, "QC", "NO", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("c58a6712-3f55-4af4-96a2-728eb4845609"), division, 06, "MB", "QC", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("e16af3e3-c55a-4843-9378-8d508b26a7b0"), division, 06, "NO", "BC", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("404a4c61-e2ac-47f8-aa84-6be6c7ad5b91"), division, 06, "SO", "NL", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("fde41198-ed1a-4427-83ac-a4d7e32454a5"), division, 06, "SK", "AB", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("c09fe1fc-1bca-4439-8952-edf4e65d78f0"), division, 07, "SK", "SO", 1, BowlingCentre.Coronation, true), new SaveMatch(new Guid("efdacb72-667a-4429-983c-d800044f0cac"), division, 07, "NL", "AB", 3, BowlingCentre.Coronation, true), new SaveMatch(new Guid("d8e94ad7-d5e5-48b7-aaf6-108671e07944"), division, 07, "MB", "NO", 5, BowlingCentre.Coronation, true), new SaveMatch(new Guid("ae153256-a02d-459d-9cd7-6df64a13b0cd"), division, 07, "BC", "QC", 7, BowlingCentre.Coronation, true), new SaveMatch(new Guid("fe156713-7abf-44ba-9cb5-6a08d30d3256"), division, 08, "SO", "BC", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("256efacc-c54f-4790-8ee4-eac8d94dc7a9"), division, 08, "NL", "NO", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("6399cfbc-e707-43ad-ae30-890aca375421"), division, 08, "QC", "SK", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("722e88d4-1007-40e8-ab52-ee4f74e5143c"), division, 08, "AB", "MB", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("c36248b6-b823-4876-ba5c-e5a88e3e8214"), division, 09, "QC", "MB", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("8ab1b6f9-6593-4725-8466-156af71d3cf4"), division, 09, "AB", "SK", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("7f16c223-dc6c-4f1f-b991-6e2d0af01ac7"), division, 09, "BC", "NO", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("c66ac46f-b6d5-4aff-8c55-cc65c1b08354"), division, 09, "NL", "SO", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("f14676bf-7efb-4446-a35c-99745c8c076a"), division, 10, "SK", "NL", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("dbfeed14-3ee1-4d20-b65f-91fad93572b2"), division, 10, "MB", "BC", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("bc1227df-0161-4825-9307-cb126d59597f"), division, 10, "SO", "AB", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("76f231f8-e3da-415d-8fe1-cda6b48e9f53"), division, 10, "NO", "QC", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("d6e7a548-bac1-4a43-adce-7b335ef3f3aa"), division, 11, "AB", "NO", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("7404813d-30d2-4240-92df-1dc0bf62afbb"), division, 11, "QC", "SO", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("ebbd50f1-3d54-4d44-9f80-88c80470c0f9"), division, 11, "MB", "NL", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("cab46263-4c21-49b9-8b4c-d7ce8c07d258"), division, 11, "SK", "BC", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("b6d024bd-9055-4109-bed2-31c9bb0e4e57"), division, 12, "MB", "SO", 03, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("a5e7efdd-8f3e-48bc-b4e9-cadb1cdde038"), division, 12, "BC", "AB", 05, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("a8561be7-7ec1-4d27-9613-e599e45a9a2c"), division, 12, "NO", "SK", 07, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("c26e89da-0db1-4b1f-a103-4454a833419d"), division, 12, "NL", "QC", 09, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("8f37a055-ec62-4030-a1f5-59c5e2aa6ddf"), division, 13, "AB", "NL", 03, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("34bacd39-f4b1-468b-9a1a-5e6a1d49fb3d"), division, 13, "SO", "SK", 05, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("d455ff08-fdad-4389-a974-74d14d0cc387"), division, 13, "QC", "BC", 07, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("ec12e59b-3631-42ff-87b9-17efaae07018"), division, 13, "NO", "MB", 09, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("557c6d59-fc6a-4668-8373-c460f9e4f943"), division, 14, "QC", "AB", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("13f78321-a2bd-42fe-b6df-c16e932f2c76"), division, 14, "NO", "SO", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("0fe72887-7e34-4a88-be6d-cc42326f6f63"), division, 14, "BC", "NL", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("095d6417-ea4a-408d-9fa6-df6d379a0886"), division, 14, "SK", "MB", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("13465706-3f6a-47a1-af2d-feb7ed07918b"), division, 15, "SK", "NO", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("9002509d-f7fa-492e-a8c0-996ec43f57f7"), division, 15, "QC", "NL", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("4669ae87-720b-4f88-bb00-783c4da803e1"), division, 15, "SO", "MB", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("67fd4d34-d96c-4d0c-8f3c-2f9800bd7c5d"), division, 15, "AB", "BC", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("3faad66d-ed24-483c-a020-fee6d97ff37c"), division, 16, "BC", "SO", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("8ca24b7e-940a-46bf-b08a-5b4d02946cde"), division, 16, "MB", "AB", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("4b7206a0-ce77-448b-a312-77d8d5f17dc4"), division, 16, "SK", "QC", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("e6dfbbc0-1046-49dd-b356-7f62336c16fd"), division, 16, "NO", "NL", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("b845110a-9c0f-4e45-9d58-0d4a2d2c649f"), division, 17, "NL", "MB", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("bd42032e-4d08-40e0-8508-50e8b1872c04"), division, 17, "BC", "SK", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("2c3d2ef0-5bbe-4696-9afc-346765ad6e8c"), division, 17, "NO", "AB", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("40662652-da9b-4c03-b8e0-63e525d354a4"), division, 17, "SO", "QC", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("0ab2b483-9fc8-4481-9e9d-654e1437f3de"), division, 18, "NO", "BC", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("affdd9ab-cafd-46bc-ab7b-3dbac6a399ff"), division, 18, "SO", "NL", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("f706e837-15ba-4a28-af0b-fc3a2e945533"), division, 18, "MB", "QC", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("c6110011-163d-410c-a30f-1505bc52ff60"), division, 18, "SK", "AB", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("7a0daf36-350e-4515-a244-d93fdfa71ba0"), division, 19, "SK", "SO", 05, BowlingCentre.Academy, true), new SaveMatch(new Guid("0b6ac538-8bc8-445e-814f-93d226aa5089"), division, 19, "NO", "MB", 07, BowlingCentre.Academy, true), new SaveMatch(new Guid("c4db9027-747a-497e-94b5-62a5ae8ef464"), division, 19, "NL", "AB", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("33120f47-b5c7-49fb-80a1-ddadec8d5dd1"), division, 19, "BC", "QC", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("00ff67bd-4f63-43e7-9182-b5bae40a49ec"), division, 20, "QC", "NO", 05, BowlingCentre.Academy, true), new SaveMatch(new Guid("baf44246-f262-4ad7-b136-fdc98d238245"), division, 20, "SK", "NL", 07, BowlingCentre.Academy, true), new SaveMatch(new Guid("0e99712d-2ee4-4559-9f1a-3ab957165fa6"), division, 20, "BC", "MB", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("3d62bf68-fe69-4b19-be36-59943f65e5f6"), division, 20, "AB", "SO", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("993dec21-76e6-4c2b-9d15-9909f82bd7c7"), division, 21, "NL", "BC", 05, BowlingCentre.Academy, true), new SaveMatch(new Guid("2d688c4d-87f5-4744-a666-7c1d6cce46a1"), division, 21, "AB", "QC", 07, BowlingCentre.Academy, true), new SaveMatch(new Guid("085e8eda-b48b-4bde-98c3-e9c8c7c7e1e2"), division, 21, "SO", "NO", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("4b0d6239-5826-41a6-937a-1b0b1e80ffb7"), division, 21, "MB", "SK", 11, BowlingCentre.Academy, true), }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
/// <summary> /// Starts the channel and initializes the MessageDispatcher. /// </summary> /// <param name="messageProtocolType">The type of message protocol used by the channel.</param> public void Start(MessageProtocolType messageProtocolType) { IMessageSerializer messageSerializer = null; if (messageProtocolType == MessageProtocolType.LanguageServer) { messageSerializer = new JsonRpcMessageSerializer(); } else { messageSerializer = new V8MessageSerializer(); } this.Initialize(messageSerializer); if (this.MessageDispatcher == null) { this.MessageDispatcher = new MessageDispatcher( this.MessageReader, this.MessageWriter); this.MessageDispatcher.Start(); } }
public async void DipatchesRequestWithParameters() { var dispatcher = new MessageDispatcher(); JObject @params = null; dispatcher.RegisterMethod("testMethod", (r) => { @params = (JObject)r["params"]; return Task.FromResult<object>(1); }); var request = new JObject( new JProperty("id", "ID"), new JProperty("method", "testMethod"), new JProperty("params", new JObject( new JProperty("a", 1), new JProperty("b", "string") )) ); var response = await dispatcher.DispatchAsync(request); Assert.Equal(1, (int)@params["a"]); Assert.Equal("string", (string)@params["b"]); }
public override void OnExit() { MessageDispatcher.RemoveListener(VrDispMessageType.SelectorPointerStatusChange.ToString(), SelectorPointerStatusChange); }
public async Task ABP_New_Loaded_Device_With_Fcnt_1_Or_0_Should_Reset_Fcnt_And_Send_To_IotHub( string twinGatewayID, uint payloadFcntUp, uint?deviceTwinFcntUp, uint?deviceTwinFcntDown) { var simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(1, gatewayID: null)); var devEUI = simulatedDevice.LoRaDevice.DeviceID; var devAddr = simulatedDevice.LoRaDevice.DevAddr; // message will be sent LoRaDeviceTelemetry loRaDeviceTelemetry = null; this.LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .Callback <LoRaDeviceTelemetry, Dictionary <string, string> >((t, _) => loRaDeviceTelemetry = t) .ReturnsAsync(true); // C2D message will be checked this.LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync((Message)null); // twin will be loaded var initialTwin = new Twin(); initialTwin.Properties.Desired[TwinProperty.DevEUI] = devEUI; initialTwin.Properties.Desired[TwinProperty.AppEUI] = simulatedDevice.LoRaDevice.AppEUI; initialTwin.Properties.Desired[TwinProperty.AppKey] = simulatedDevice.LoRaDevice.AppKey; initialTwin.Properties.Desired[TwinProperty.NwkSKey] = simulatedDevice.LoRaDevice.NwkSKey; initialTwin.Properties.Desired[TwinProperty.AppSKey] = simulatedDevice.LoRaDevice.AppSKey; initialTwin.Properties.Desired[TwinProperty.DevAddr] = devAddr; if (twinGatewayID != null) { initialTwin.Properties.Desired[TwinProperty.GatewayID] = twinGatewayID; } initialTwin.Properties.Desired[TwinProperty.SensorDecoder] = simulatedDevice.LoRaDevice.SensorDecoder; if (deviceTwinFcntDown.HasValue) { initialTwin.Properties.Reported[TwinProperty.FCntDown] = deviceTwinFcntDown.Value; } if (deviceTwinFcntUp.HasValue) { initialTwin.Properties.Reported[TwinProperty.FCntUp] = deviceTwinFcntUp.Value; } this.LoRaDeviceClient.Setup(x => x.GetTwinAsync()).ReturnsAsync(initialTwin); // twin will be updated with new fcnt int?fcntUpSavedInTwin = null; int?fcntDownSavedInTwin = null; var shouldSaveTwin = (deviceTwinFcntDown ?? 0) != 0 || (deviceTwinFcntUp ?? 0) != 0; if (shouldSaveTwin) { this.LoRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>())) .Callback <TwinCollection>((t) => { fcntUpSavedInTwin = (int)t[TwinProperty.FCntUp]; fcntDownSavedInTwin = (int)t[TwinProperty.FCntDown]; }) .ReturnsAsync(true); } this.LoRaDeviceApi.Setup(x => x.ABPFcntCacheResetAsync(devEUI, It.IsAny <uint>(), It.IsNotNull <string>())) .ReturnsAsync(true); // device api will be searched for payload this.LoRaDeviceApi.Setup(x => x.SearchByDevAddrAsync(devAddr)) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(devAddr, devEUI, "abc").AsList())); var memoryCache = new MemoryCache(new MemoryCacheOptions()); var deviceRegistry = new LoRaDeviceRegistry(this.ServerConfiguration, memoryCache, this.LoRaDeviceApi.Object, this.LoRaDeviceFactory); // Send to message processor var messageDispatcher = new MessageDispatcher( this.ServerConfiguration, deviceRegistry, this.FrameCounterUpdateStrategyProvider); // sends unconfirmed message var unconfirmedMessagePayload = simulatedDevice.CreateUnconfirmedDataUpMessage("hello", fcnt: payloadFcntUp); var rxpk = unconfirmedMessagePayload.SerializeUplink(simulatedDevice.AppSKey, simulatedDevice.NwkSKey).Rxpk[0]; var request = this.CreateWaitableRequest(rxpk); messageDispatcher.DispatchRequest(request); Assert.True(await request.WaitCompleteAsync()); Assert.Null(request.ResponseDownlink); // Ensure that a telemetry was sent Assert.NotNull(loRaDeviceTelemetry); // Ensure that the device twins were saved if (shouldSaveTwin) { Assert.NotNull(fcntDownSavedInTwin); Assert.NotNull(fcntUpSavedInTwin); Assert.Equal(0, fcntDownSavedInTwin.Value); Assert.Equal(0, fcntUpSavedInTwin.Value); } // verify that the device in device registry has correct properties and frame counters var devicesForDevAddr = deviceRegistry.InternalGetCachedDevicesForDevAddr(devAddr); Assert.Single(devicesForDevAddr); Assert.True(devicesForDevAddr.TryGetValue(devEUI, out var loRaDevice)); Assert.Equal(devAddr, loRaDevice.DevAddr); Assert.Equal(devEUI, loRaDevice.DevEUI); Assert.True(loRaDevice.IsABP); Assert.Equal(payloadFcntUp, loRaDevice.FCntUp); Assert.Equal(0U, loRaDevice.FCntDown); if (payloadFcntUp == 0) { Assert.False(loRaDevice.HasFrameCountChanges); // no changes } else { Assert.True(loRaDevice.HasFrameCountChanges); // should have changes! } this.LoRaDeviceClient.VerifyAll(); this.LoRaDeviceApi.VerifyAll(); }
// [InlineData(200, 500, 100, 100, 1)] public async Task When_Multiple_Devices_And_Conflicting_DevAddr_Send_Telemetry_Queue_Sends_Messages_To_IoTHub( int searchDelay, int getTwinDelay, int sendMessageDelay, int receiveDelay, int delayBetweenMessages) { const int messagePerDeviceCount = 10; const int payloadInitialFcnt = 2; var device1 = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(1)); var device1Twin = TestUtils.CreateABPTwin(device1); var device2 = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(2)) { DevAddr = device1.DevAddr }; var device2Twin = TestUtils.CreateABPTwin(device2); var device3 = new SimulatedDevice(TestDeviceInfo.CreateOTAADevice(3)); device3.SetupJoin(TestKeys.CreateAppSessionKey(0x88), TestKeys.CreateNetworkSessionKey(0x88), new DevAddr(0x02000088)); var device3Twin = TestUtils.CreateOTAATwin(device3); var device4 = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(4)); var device4Twin = TestUtils.CreateABPTwin(device4); var device1And2Result = new IoTHubDeviceInfo[] { new IoTHubDeviceInfo(device1.DevAddr, device1.DevEUI, "1"), new IoTHubDeviceInfo(device2.DevAddr, device2.DevEUI, "2"), }; LoRaDeviceApi.Setup(x => x.SearchByDevAddrAsync(device1.DevAddr.Value)) .ReturnsAsync(new SearchDevicesResult(device1And2Result), TimeSpan.FromMilliseconds(searchDelay)); LoRaDeviceApi.Setup(x => x.SearchByDevAddrAsync(device3.DevAddr.Value)) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(device3.DevAddr, device3.DevEUI, "3").AsList()), TimeSpan.FromMilliseconds(searchDelay)); LoRaDeviceApi.Setup(x => x.SearchByDevAddrAsync(device4.DevAddr.Value)) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(device4.DevAddr, device4.DevEUI, "3").AsList()), TimeSpan.FromMilliseconds(searchDelay)); var deviceClient1 = new Mock <ILoRaDeviceClient>(); var deviceClient1Telemetry = new List <LoRaDeviceTelemetry>(); deviceClient1.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(device1Twin, TimeSpan.FromMilliseconds(getTwinDelay)); deviceClient1.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .Callback <LoRaDeviceTelemetry, Dictionary <string, string> >((t, d) => deviceClient1Telemetry.Add(t)) .ReturnsAsync(true, TimeSpan.FromMilliseconds(sendMessageDelay)); deviceClient1.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync(null, TimeSpan.FromMilliseconds(receiveDelay)); deviceClient1.Setup(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); var deviceClient2 = new Mock <ILoRaDeviceClient>(); var deviceClient2Telemetry = new List <LoRaDeviceTelemetry>(); deviceClient2.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(device2Twin, TimeSpan.FromMilliseconds(getTwinDelay)); deviceClient2.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .Callback <LoRaDeviceTelemetry, Dictionary <string, string> >((t, d) => deviceClient2Telemetry.Add(t)) .ReturnsAsync(true, TimeSpan.FromMilliseconds(sendMessageDelay)); deviceClient2.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync(null, TimeSpan.FromMilliseconds(receiveDelay)); deviceClient2.Setup(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); var deviceClient3 = new Mock <ILoRaDeviceClient>(); var deviceClient3Telemetry = new List <LoRaDeviceTelemetry>(); deviceClient3.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(device3Twin, TimeSpan.FromMilliseconds(getTwinDelay)); deviceClient3.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .Callback <LoRaDeviceTelemetry, Dictionary <string, string> >((t, d) => deviceClient3Telemetry.Add(t)) .ReturnsAsync(true, TimeSpan.FromMilliseconds(sendMessageDelay)); deviceClient3.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync(null, TimeSpan.FromMilliseconds(receiveDelay)); deviceClient3.Setup(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); var deviceClient4 = new Mock <ILoRaDeviceClient>(); var deviceClient4Telemetry = new List <LoRaDeviceTelemetry>(); deviceClient4.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(device4Twin, TimeSpan.FromMilliseconds(getTwinDelay)); deviceClient4.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .Callback <LoRaDeviceTelemetry, Dictionary <string, string> >((t, d) => deviceClient4Telemetry.Add(t)) .ReturnsAsync(true, TimeSpan.FromMilliseconds(sendMessageDelay)); deviceClient4.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync(null, TimeSpan.FromMilliseconds(receiveDelay)); deviceClient4.Setup(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); LoRaDeviceFactory.SetClient(device1.DevEUI, deviceClient1.Object); LoRaDeviceFactory.SetClient(device2.DevEUI, deviceClient2.Object); LoRaDeviceFactory.SetClient(device3.DevEUI, deviceClient3.Object); LoRaDeviceFactory.SetClient(device4.DevEUI, deviceClient4.Object); using var cache = NewMemoryCache(); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, DeviceCache); using var messageDispatcher = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var device1Messages = await SendMessages(device1, messageDispatcher, payloadInitialFcnt, delayBetweenMessages, messagePerDeviceCount); var device2Messages = await SendMessages(device2, messageDispatcher, payloadInitialFcnt, delayBetweenMessages, messagePerDeviceCount); var device3Messages = await SendMessages(device3, messageDispatcher, payloadInitialFcnt, delayBetweenMessages, messagePerDeviceCount); var device4Messages = await SendMessages(device4, messageDispatcher, payloadInitialFcnt, delayBetweenMessages, messagePerDeviceCount); var allMessages = device1Messages .Concat(device2Messages) .Concat(device3Messages) .Concat(device4Messages) .ToList(); Assert.Equal(messagePerDeviceCount * 4, allMessages.Count); await Task.WhenAll(allMessages.Select(x => x.WaitCompleteAsync())); Assert.All(allMessages, m => Assert.True(m.ProcessingSucceeded)); var telemetries = new[] { deviceClient1Telemetry, deviceClient2Telemetry, deviceClient3Telemetry, deviceClient4Telemetry }; foreach (var telemetry in telemetries) { Assert.Equal(messagePerDeviceCount, telemetry.Count); for (var i = 0; i < messagePerDeviceCount; ++i) { Assert.Equal(payloadInitialFcnt + i, telemetry[i].Fcnt); } } deviceClient1.VerifyAll(); deviceClient1.Verify(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null), Times.Exactly(messagePerDeviceCount)); deviceClient2.VerifyAll(); deviceClient2.Verify(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null), Times.Exactly(messagePerDeviceCount)); deviceClient3.VerifyAll(); deviceClient3.Verify(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null), Times.Exactly(messagePerDeviceCount)); deviceClient4.VerifyAll(); deviceClient4.Verify(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null), Times.Exactly(messagePerDeviceCount)); LoRaDeviceApi.VerifyAll(); }
public async Task ABP_Load_And_Receiving_Multiple_Unconfirmed_Should_Send_All_ToHub(ParallelTestConfiguration parallelTestConfiguration) { Console.WriteLine("---"); var simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(parallelTestConfiguration.DeviceID ?? 1, gatewayID: null)); var devEui = simulatedDevice.LoRaDevice.DevEui; var devAddr = simulatedDevice.LoRaDevice.DevAddr.Value; // Using loose mock because sometimes we might call receive async var looseDeviceClient = new Mock <ILoRaDeviceClient>(MockBehavior.Loose); LoRaDeviceFactory.SetClient(devEui, looseDeviceClient.Object); looseDeviceClient.Setup(x => x.ReceiveAsync(It.IsAny <TimeSpan>())) .ReturnsAsync((Message)null); // message will be sent var sentTelemetry = new List <LoRaDeviceTelemetry>(); looseDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .Returns <LoRaDeviceTelemetry, Dictionary <string, string> >((t, _) => { sentTelemetry.Add(t); var duration = parallelTestConfiguration.SendEventDuration.Next(); Console.WriteLine($"{nameof(looseDeviceClient.Object.SendEventAsync)} sleeping for {duration}"); return(Task.Delay(duration) .ContinueWith((a) => true, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }); // twin will be loaded var initialTwin = new Twin(); initialTwin.Properties.Desired[TwinProperty.DevEUI] = devEui.ToString(); initialTwin.Properties.Desired[TwinProperty.AppEui] = simulatedDevice.LoRaDevice.AppEui?.ToString(); initialTwin.Properties.Desired[TwinProperty.AppKey] = simulatedDevice.LoRaDevice.AppKey?.ToString(); initialTwin.Properties.Desired[TwinProperty.NwkSKey] = simulatedDevice.LoRaDevice.NwkSKey?.ToString(); initialTwin.Properties.Desired[TwinProperty.AppSKey] = simulatedDevice.LoRaDevice.AppSKey?.ToString(); initialTwin.Properties.Desired[TwinProperty.DevAddr] = devAddr.ToString(); if (parallelTestConfiguration.GatewayID != null) { initialTwin.Properties.Desired[TwinProperty.GatewayID] = parallelTestConfiguration.GatewayID; } initialTwin.Properties.Desired[TwinProperty.SensorDecoder] = simulatedDevice.LoRaDevice.SensorDecoder; if (parallelTestConfiguration.DeviceTwinFcntDown.HasValue) { initialTwin.Properties.Reported[TwinProperty.FCntDown] = parallelTestConfiguration.DeviceTwinFcntDown.Value; } if (parallelTestConfiguration.DeviceTwinFcntUp.HasValue) { initialTwin.Properties.Reported[TwinProperty.FCntUp] = parallelTestConfiguration.DeviceTwinFcntUp.Value; } looseDeviceClient.Setup(x => x.GetTwinAsync(CancellationToken.None)) .Returns(() => { var duration = parallelTestConfiguration.LoadTwinDuration.Next(); Console.WriteLine($"{nameof(looseDeviceClient.Object.GetTwinAsync)} sleeping for {duration}"); return(Task.Delay(duration) .ContinueWith(_ => initialTwin, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }); // twin will be updated with new fcnt var expectedToSaveTwin = parallelTestConfiguration.DeviceTwinFcntDown > 0 || parallelTestConfiguration.DeviceTwinFcntUp > 0; uint?fcntUpSavedInTwin = null; uint?fcntDownSavedInTwin = null; if (expectedToSaveTwin) { looseDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>())) .Returns <TwinCollection, CancellationToken>((t, _) => { fcntUpSavedInTwin = (uint)t[TwinProperty.FCntUp]; fcntDownSavedInTwin = (uint)t[TwinProperty.FCntDown]; var duration = parallelTestConfiguration.UpdateTwinDuration.Next(); Console.WriteLine($"{nameof(looseDeviceClient.Object.UpdateReportedPropertiesAsync)} sleeping for {duration}"); return(Task.Delay(duration, CancellationToken.None) .ContinueWith((a) => true, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }); } if (expectedToSaveTwin && string.IsNullOrEmpty(parallelTestConfiguration.GatewayID)) { LoRaDeviceApi.Setup(x => x.ABPFcntCacheResetAsync(devEui, It.IsAny <uint>(), It.IsNotNull <string>())) .Returns(() => { var duration = parallelTestConfiguration.DeviceApiResetFcntDuration.Next(); Console.WriteLine($"{nameof(LoRaDeviceApi.Object.ABPFcntCacheResetAsync)} sleeping for {duration}"); return(Task.Delay(duration) .ContinueWith((a) => true, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }); } // device api will be searched for payload LoRaDeviceApi.Setup(x => x.SearchByDevAddrAsync(devAddr)) .Returns(() => { var duration = parallelTestConfiguration.SearchByDevAddrDuration.Next(); Console.WriteLine($"{nameof(LoRaDeviceApi.Object.SearchByDevAddrAsync)} sleeping for {duration}"); return(Task.Delay(duration) .ContinueWith((a) => new SearchDevicesResult(new IoTHubDeviceInfo(devAddr, devEui, "abc").AsList()), CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }); using var memoryCache = new MemoryCache(new MemoryCacheOptions()); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, memoryCache, LoRaDeviceApi.Object, LoRaDeviceFactory, DeviceCache); // Send to message processor using var messageDispatcher = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); // sends unconfirmed message var unconfirmedMessage1 = simulatedDevice.CreateUnconfirmedDataUpMessage("1", fcnt: 1); var unconfirmedMessage2 = simulatedDevice.CreateUnconfirmedDataUpMessage("2", fcnt: 2); var unconfirmedMessage3 = simulatedDevice.CreateUnconfirmedDataUpMessage("3", fcnt: 3); var req1 = CreateWaitableRequest(unconfirmedMessage1, this.downstreamMessageSender); messageDispatcher.DispatchRequest(req1); await Task.Delay(parallelTestConfiguration.BetweenMessageDuration.Next()); var req2 = CreateWaitableRequest(unconfirmedMessage2, this.downstreamMessageSender); messageDispatcher.DispatchRequest(req2); await Task.Delay(parallelTestConfiguration.BetweenMessageDuration.Next()); var req3 = CreateWaitableRequest(unconfirmedMessage3, this.downstreamMessageSender); messageDispatcher.DispatchRequest(req3); await Task.Delay(parallelTestConfiguration.BetweenMessageDuration.Next()); await Task.WhenAll(req1.WaitCompleteAsync(20000), req2.WaitCompleteAsync(20000), req3.WaitCompleteAsync(20000)); var allRequests = new[] { req1, req2, req3 }; Assert.All(allRequests, x => Assert.Null(x.ResponseDownlink)); Assert.All(allRequests, x => Assert.True(x.ProcessingSucceeded)); looseDeviceClient.Verify(x => x.GetTwinAsync(CancellationToken.None), Times.Exactly(1)); if (expectedToSaveTwin) { looseDeviceClient.Verify(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>()), Times.Exactly(1)); } LoRaDeviceApi.Verify(x => x.SearchByDevAddrAsync(devAddr), Times.Once); // Ensure that all telemetry was sent Assert.Equal(3, sentTelemetry.Count); // Ensure data was sent in order Assert.Equal(1, sentTelemetry[0].Fcnt); Assert.Equal(2, sentTelemetry[1].Fcnt); Assert.Equal(3, sentTelemetry[2].Fcnt); // Ensure that the device twins were saved if (expectedToSaveTwin) { Assert.NotNull(fcntDownSavedInTwin); Assert.NotNull(fcntUpSavedInTwin); Assert.Equal(0U, fcntDownSavedInTwin.Value); Assert.Equal(0U, fcntUpSavedInTwin.Value); } // verify that the device in device registry has correct properties and frame counters Assert.True(DeviceCache.TryGetForPayload(req1.Payload, out var loRaDevice)); Assert.Equal(devAddr, loRaDevice.DevAddr); Assert.Equal(devEui, loRaDevice.DevEUI); Assert.True(loRaDevice.IsABP); Assert.Equal(3U, loRaDevice.FCntUp); Assert.Equal(0U, loRaDevice.FCntDown); Assert.True(loRaDevice.HasFrameCountChanges); // should have changes! // looseDeviceClient.VerifyAll(); LoRaDeviceApi.VerifyAll(); }
static void Main(string[] args) { //Debugger.Launch(); if (args.Length == 0) ExitWithError("Must specify container-id as the first argument.", -1); containerId = args[0]; hostJobObject = new JobObject(null); hostProcess = ProcessHelper.WrapProcess(Process.GetCurrentProcess()); var input = Console.In; var output = Console.Out; using (var transport = MessageTransport.Create(input, output)) { processTracker = new ProcessTracker(transport, hostJobObject, hostProcess, new ProcessHelper()); var createProcessHandler = new CreateProcessHandler(new ProcessRunner(), processTracker); var pingHandler = new PingHandler(); var findProcessByIdHandler = new FindProcessByIdHandler(processTracker); var stopProcessHandler = new StopProcessHandler(processTracker); var stopAllProcessesHandler = new StopAllProcessesHandler(processTracker); var waitForProcessExitHandler = new WaitForProcessExitHandler(processTracker); var dispatcher = new MessageDispatcher(); dispatcher.RegisterMethod<CreateProcessRequest>( CreateProcessRequest.MethodName, async (request) => { var result = await createProcessHandler.ExecuteAsync(request.@params); return new CreateProcessResponse(request.id, result); }); dispatcher.RegisterMethod<PingRequest>( PingRequest.MethodName, async (request) => { await pingHandler.ExecuteAsync(); return new PingResponse(request.id); }); dispatcher.RegisterMethod<FindProcessByIdRequest>( FindProcessByIdRequest.MethodName, async (request) => { var result = await findProcessByIdHandler.ExecuteAsync(request.@params); return new FindProcessByIdResponse(request.id, result); }); dispatcher.RegisterMethod<StopProcessRequest>( StopProcessRequest.MethodName, async (request) => { await stopProcessHandler.ExecuteAsync(request.@params); return new StopProcessResponse(request.id); }); dispatcher.RegisterMethod<StopAllProcessesRequest>( StopAllProcessesRequest.MethodName, async (request) => { await stopAllProcessesHandler.ExecuteAsync(request.@params); return new StopAllProcessesResponse(request.id); }); dispatcher.RegisterMethod<WaitForProcessExitRequest>( WaitForProcessExitRequest.MethodName, async (request) => { var result = await waitForProcessExitHandler.ExecuteAsync(request.@params); return new WaitForProcessExitResponse(request.id, result); }); transport.SubscribeRequest( async (request) => { var response = await dispatcher.DispatchAsync(request); await transport.PublishResponseAsync(response); }); transport.Start(); ReportOk(); exitEvent.WaitOne(); } }
private void OnDestroy() { MessageDispatcher.RemoveListener(VrDispMessageType.VRPlaycePointEnter.ToString(), VRTelePointEnter); MessageDispatcher.RemoveListener(VrDispMessageType.VRPlaycePointExit.ToString(), VRTelePointExit); }
public async Task When_Updating_PreferredGateway_And_FcntUp_Should_Save_Twin_Once() { const uint PayloadFcnt = 10; const uint InitialDeviceFcntUp = 9; const uint InitialDeviceFcntDown = 20; var simulatedDevice = new SimulatedDevice( TestDeviceInfo.CreateABPDevice(1, deviceClassType: 'c'), frmCntUp: InitialDeviceFcntUp, frmCntDown: InitialDeviceFcntDown); var loraDevice = CreateLoRaDevice(simulatedDevice); loraDevice.UpdatePreferredGatewayID("another-gateway", acceptChanges: true); var bundlerResult = new FunctionBundlerResult() { PreferredGatewayResult = new PreferredGatewayResult() { DevEUI = simulatedDevice.DevEUI, PreferredGatewayID = ServerGatewayID, CurrentFcntUp = PayloadFcnt, RequestFcntUp = PayloadFcnt, } }; LoRaDeviceApi .Setup(x => x.ExecuteFunctionBundlerAsync(simulatedDevice.DevEUI, It.Is((FunctionBundlerRequest r) => PayloadFcnt == r.ClientFCntUp && ServerGatewayID == r.GatewayId && FunctionBundlerItemType.PreferredGateway == r.FunctionItems))) .ReturnsAsync(bundlerResult); TwinCollection actualSavedTwin = null; LoRaDeviceClient .Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>())) .Callback <TwinCollection, CancellationToken>((savedTwin, _) => actualSavedTwin = savedTwin) .ReturnsAsync(true); LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .ReturnsAsync(true); LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsAny <TimeSpan>())) .ReturnsAsync((Message)null); using var cache = EmptyMemoryCache(); using var loraDeviceCache = CreateDeviceCache(loraDevice); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, loraDeviceCache); // Send to message processor using var messageProcessor = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var payload = simulatedDevice.CreateUnconfirmedDataUpMessage("1234", fcnt: PayloadFcnt); using var request = CreateWaitableRequest(payload); messageProcessor.DispatchRequest(request); Assert.True(await request.WaitCompleteAsync()); // Expectations // 1. Message was sent to IoT Hub LoRaDeviceClient.VerifyAll(); LoRaDeviceApi.VerifyAll(); // 2. No downstream message for the current device is sent Assert.Null(request.ResponseDownlink); Assert.True(request.ProcessingSucceeded); Assert.Equal(ServerGatewayID, loraDevice.PreferredGatewayID); Assert.Equal(LoRaRegionType.EU868, loraDevice.LoRaRegion); Assert.Equal(PayloadFcnt, loraDevice.FCntUp); LoRaDeviceClient.Verify(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>()), Times.Once()); Assert.Equal(ServerGatewayID, actualSavedTwin[TwinProperty.PreferredGatewayID].Value as string); Assert.Equal(LoRaRegionType.EU868.ToString(), actualSavedTwin[TwinProperty.Region].Value as string); Assert.Equal(PayloadFcnt, (uint)actualSavedTwin[TwinProperty.FCntUp].Value); }
public static void TournamentMenSingle(MessageDispatcher dispatcher) { var scheduleId = new Guid("defd5a4a-4896-4eac-ba16-4e1302bec46b"); var division = "Tournament Men Single"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("56ca5e66-9699-42fd-b5c5-a141c4c2f86d"), division, 01, "SO", "AB", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("85209746-7fd8-4af3-ac11-79ec1bafc8d0"), division, 01, "NO", "MB", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("ddc437fc-4760-4a21-8d81-882960a8218a"), division, 01, "BC", "NL", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("c6d51abb-3618-4c0d-a3bc-436757677b2c"), division, 01, "QC", "SK", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("d4174f7c-bd4c-40e7-a33b-f6cfafc6780d"), division, 02, "BC", "SK", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("0b2c7722-b045-45e5-9a73-63b4f20d0d1d"), division, 02, "NL", "QC", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("548db1a7-2ef5-40a6-a6d6-57cbdf2344cd"), division, 02, "MB", "SO", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("db574d9f-c7a2-4fff-bce5-6a997d0a2ca0"), division, 02, "AB", "NO", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("87106ecf-0aad-4898-86ed-48e5a58ec93f"), division, 03, "NL", "NO", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("cb8a770f-2181-4d57-b783-760e937d12af"), division, 03, "SK", "SO", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("32e967c5-85fc-466c-bb1d-0680460b9a08"), division, 03, "QC", "AB", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("5e002afb-5cf3-4bab-ac40-3feb9084df5c"), division, 03, "MB", "BC", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("93e5ee03-ab14-4460-ae6e-82793f6c6960"), division, 04, "QC", "MB", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("b20f7625-4ad0-4ede-9c69-15ccf9c43b95"), division, 04, "AB", "BC", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("5bc18a6a-f462-4820-ad36-5229457fbf42"), division, 04, "NO", "SK", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("5a7a77d1-5f6c-418a-aed9-5f5fad6e3035"), division, 04, "SO", "NL", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("953e6064-e396-4945-b3f9-e093148cb4d6"), division, 05, "SK", "AB", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("416cefd5-12b6-4939-af54-38567eda5188"), division, 05, "MB", "NL", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("6b3d1096-096b-444d-b7f7-7827b0997d58"), division, 05, "SO", "QC", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("10049fa0-8218-40e6-8348-f624b89062e5"), division, 05, "BC", "NO", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("e5181234-4062-45c9-a9c5-f1f81150a1e2"), division, 06, "NO", "SO", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("24e53524-7a89-4060-87f6-3ef9741ec4fc"), division, 06, "BC", "QC", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("9265f331-4aee-405c-9c23-fa66fdb4b877"), division, 06, "NL", "SK", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("3a386947-ce13-4d9f-b5ff-ae9be20d713a"), division, 06, "AB", "MB", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("e1307cf7-ee33-45e0-8175-869d6fb005f9"), division, 07, "AB", "NL", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("db1fed25-a598-4394-a725-e21620aa4d0e"), division, 07, "SK", "MB", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("cd960c65-a32f-42aa-83a0-dcdd1c5ecb97"), division, 07, "QC", "NO", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("a315c988-866a-49bd-9e34-e6d5c9df6e98"), division, 07, "SO", "BC", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("ddf0117a-c6ef-4d53-a43f-ed52bca28bcb"), division, 08, "SO", "NL", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("75f83afe-7275-4d5c-a274-93be62c42c85"), division, 08, "MB", "QC", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("eab986f5-e9d1-48ae-b60a-7a84fd552cd0"), division, 08, "BC", "AB", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("a4d5195b-c72e-4974-b6b4-490933dffaba"), division, 08, "SK", "NO", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("ad627756-89a3-4a2f-8ccc-76179b1dde01"), division, 09, "SK", "BC", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("e45d11ea-4190-4960-a34f-aa1705a1b2f1"), division, 09, "NO", "AB", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("90a427ba-2c96-4428-b08b-70b89bdbacd3"), division, 09, "QC", "NL", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("f7be7c7c-0a7d-4850-bc59-8d6f377343e0"), division, 09, "SO", "MB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("d2c1b4de-7a25-4c51-96a7-23294ab6b968"), division, 10, "NO", "QC", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("d4c90072-4a25-4b04-8fda-2cb8bd91f7ba"), division, 10, "BC", "SO", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("3be33973-5cba-41c0-a448-9163f01213f9"), division, 10, "MB", "SK", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("adb139d0-c477-4b3c-af59-740e16186de6"), division, 10, "NL", "AB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("b2a6f30b-986a-434d-a949-70daca6ca91d"), division, 11, "MB", "AB", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("a1ddc070-17a3-4782-8d6c-143299f754f5"), division, 11, "SK", "NL", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("7f055841-05c9-4f98-84a6-eb847747c906"), division, 11, "SO", "NO", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("411775e9-d03a-4be7-a506-d3b7b1c6f7f7"), division, 11, "QC", "BC", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("82cf1637-988e-4b36-bb45-0f7770912b3e"), division, 12, "QC", "SO", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("0f97150d-67e7-49a4-8e91-96d4eebb39a1"), division, 12, "NO", "BC", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("eef6d610-6a4d-49a9-a850-3c14c06e301b"), division, 12, "NL", "MB", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("70b94504-2f75-4966-b8eb-9f8e70ffbaad"), division, 12, "AB", "SK", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("989f97ed-2c8d-4576-9ad7-14cea465b6b4"), division, 13, "NO", "NL", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("e56db559-2d93-4d43-ab19-c99c7f46932d"), division, 13, "SO", "SK", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("9402c9e1-bb8a-4e4e-a4fe-53f6cc053ebd"), division, 13, "AB", "QC", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("208257c1-9be6-4c32-97b4-cc7ec5b0a69f"), division, 13, "BC", "MB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("1097fa30-bc2c-48f6-8583-2658c486126f"), division, 14, "AB", "SO", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("58c44992-23f6-4074-83f3-46a5bef06ee2"), division, 14, "MB", "NO", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("50b6b896-20a4-4871-b444-62209ef39251"), division, 14, "NL", "BC", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("dba4caf5-7cac-4818-a0f0-09915b50d781"), division, 14, "SK", "QC", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("687c2a6c-773f-4599-a84f-dcdb5e04f9ca"), division, 15, "SK", "AB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("de19eb86-2917-4747-a8fb-614b24e7508f"), division, 15, "MB", "NL", 25, BowlingCentre.Academy), new SaveMatch(new Guid("e7ef62c1-b578-4e45-bdff-9d0536cd039c"), division, 15, "QC", "SO", 27, BowlingCentre.Academy), new SaveMatch(new Guid("742ebf23-6172-44ab-9efe-360e3d9d4b52"), division, 15, "BC", "NO", 29, BowlingCentre.Academy), new SaveMatch(new Guid("bc13fba1-7fd5-437b-b86d-7f07f2b0ccb5"), division, 16, "SO", "BC", 23, BowlingCentre.Academy), new SaveMatch(new Guid("b520d183-c7e6-4e70-afbb-ee0fd60b53f1"), division, 16, "QC", "NO", 25, BowlingCentre.Academy), new SaveMatch(new Guid("54c445e5-2257-47cd-b903-0f14a3f00595"), division, 16, "MB", "SK", 27, BowlingCentre.Academy), new SaveMatch(new Guid("9b17c243-e2f4-4319-ab5c-408ea5aa5117"), division, 16, "NL", "AB", 29, BowlingCentre.Academy), new SaveMatch(new Guid("e30344fd-802a-4982-8eef-f6e45630e8d1"), division, 17, "NO", "MB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("2bc2cec3-23f4-4305-9259-7ae51d9f25e8"), division, 17, "SO", "AB", 25, BowlingCentre.Academy), new SaveMatch(new Guid("538f4733-c480-4499-9b25-6c41efe39c26"), division, 17, "BC", "NL", 27, BowlingCentre.Academy), new SaveMatch(new Guid("8882b4cc-9b0b-41cb-bbe4-e52b72c1c14c"), division, 17, "SK", "QC", 29, BowlingCentre.Academy), new SaveMatch(new Guid("7858e184-eb08-47f5-a044-eb8fe5a900dd"), division, 18, "NL", "SK", 23, BowlingCentre.Academy), new SaveMatch(new Guid("290cb5f9-b5a4-42ab-8912-27259ea3f607"), division, 18, "BC", "QC", 25, BowlingCentre.Academy), new SaveMatch(new Guid("b759df83-6f07-43a1-bc0a-0e55bd39b805"), division, 18, "AB", "MB", 27, BowlingCentre.Academy), new SaveMatch(new Guid("49552007-2853-4813-bc07-fb7ed613ec6e"), division, 18, "NO", "SO", 29, BowlingCentre.Academy), new SaveMatch(new Guid("707b6c37-e79c-4a00-a461-946c33fa635b"), division, 19, "AB", "BC", 23, BowlingCentre.Academy), new SaveMatch(new Guid("8ae80205-c93e-4aa5-82a1-a7fccbfdca6c"), division, 19, "SK", "NO", 25, BowlingCentre.Academy), new SaveMatch(new Guid("3237f288-bd82-431d-94d3-763e1466c1c0"), division, 19, "NL", "SO", 27, BowlingCentre.Academy), new SaveMatch(new Guid("6a4dd345-07ed-4f22-bb2f-2f2a9d395155"), division, 19, "QC", "MB", 29, BowlingCentre.Academy), new SaveMatch(new Guid("4e2511f3-1251-4ab9-9ae1-79bd381be3b8"), division, 20, "NO", "NL", 23, BowlingCentre.Academy), new SaveMatch(new Guid("542b2d1d-6450-4393-a196-4f0a1802831e"), division, 20, "MB", "BC", 25, BowlingCentre.Academy), new SaveMatch(new Guid("b1e1d892-ba60-4f92-ba93-e80518588f7d"), division, 20, "QC", "AB", 27, BowlingCentre.Academy), new SaveMatch(new Guid("4bcb4a97-a1e6-41c6-9ef8-87473b0b01af"), division, 20, "SO", "SK", 29, BowlingCentre.Academy), new SaveMatch(new Guid("4c81e4e2-a010-4635-a714-e15ee04fc44e"), division, 21, "MB", "SO", 23, BowlingCentre.Academy), new SaveMatch(new Guid("d9a3d812-1e31-461f-8fe4-dadf0042a193"), division, 21, "NL", "QC", 25, BowlingCentre.Academy), new SaveMatch(new Guid("8cd0b7b9-29fb-435d-9fc2-59e30424182e"), division, 21, "BC", "SK", 27, BowlingCentre.Academy), new SaveMatch(new Guid("b1ee9924-7b1f-4ebc-8f9a-a17519e7690a"), division, 21, "AB", "NO", 29, BowlingCentre.Academy), }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
public static void TournamentMen(MessageDispatcher dispatcher) { var scheduleId = new Guid("3ab4cdc0-be00-4391-ba53-ec95ce0a318a"); var division = "Tournament Men"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("35622ef1-fe65-4384-84ba-debd3368dcfb"), division, 01, "NO", "BC", 09, BowlingCentre.Rossmere), new SaveMatch(new Guid("e8b04e20-7c9c-4f86-bd02-44e6da6608aa"), division, 01, "MB", "AB", 11, BowlingCentre.Rossmere), new SaveMatch(new Guid("9c4875b2-09e9-424e-b656-fb6f692e35dd"), division, 01, "QC", "SK", 13, BowlingCentre.Rossmere), new SaveMatch(new Guid("8cf043fd-7c24-4ec3-84c0-649e680446c2"), division, 01, "NL", "SO", 19, BowlingCentre.Rossmere), new SaveMatch(new Guid("15aeaa82-5dcd-49b1-a59b-44440b400a08"), division, 02, "SO", "NO", 13, BowlingCentre.Rossmere), new SaveMatch(new Guid("d0ddb4e4-f715-4ba7-8ca6-9ca0fd546f3f"), division, 02, "AB", "QC", 15, BowlingCentre.Rossmere), new SaveMatch(new Guid("cd5871f6-03f8-498b-ac1c-cb4aa5ce11ab"), division, 02, "BC", "NL", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("e0fac3c0-c1f8-466f-a79a-d1fb6954abf7"), division, 02, "MB", "SK", 19, BowlingCentre.Rossmere), new SaveMatch(new Guid("1fd78993-7ecf-46af-9ef9-9b7087096f56"), division, 03, "AB", "SK", 09, BowlingCentre.Rossmere), new SaveMatch(new Guid("d5ca0ccc-c032-4608-95c7-7765e7f98f9b"), division, 03, "BC", "SO", 11, BowlingCentre.Rossmere), new SaveMatch(new Guid("2adf882d-186e-47f7-8c6a-7a575cc32d86"), division, 03, "NO", "NL", 15, BowlingCentre.Rossmere), new SaveMatch(new Guid("4722af0f-0ffc-420f-afa8-66a86e905356"), division, 03, "QC", "MB", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("01cd834a-f9fa-428f-860e-21806fcd96c3"), division, 04, "NL", "AB", 13, BowlingCentre.Rossmere), new SaveMatch(new Guid("59d3d535-801e-4780-950a-1b9041a987d2"), division, 04, "MB", "SO", 15, BowlingCentre.Rossmere), new SaveMatch(new Guid("97e6f977-8d85-4c03-838a-064b2da0cd7e"), division, 04, "SK", "NO", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("516a7558-7cc5-498d-a43d-4a60f5a7ee5b"), division, 04, "QC", "BC", 19, BowlingCentre.Rossmere), new SaveMatch(new Guid("7877c4cf-9419-4a49-ac8b-bb5a03f9559e"), division, 05, "SO", "QC", 09, BowlingCentre.Rossmere), new SaveMatch(new Guid("ed290581-c2ff-4760-8fe4-212f3ae6f56e"), division, 05, "SK", "NL", 11, BowlingCentre.Rossmere), new SaveMatch(new Guid("fbe87711-d30d-421d-b084-7e587872a6ff"), division, 05, "MB", "BC", 13, BowlingCentre.Rossmere), new SaveMatch(new Guid("16f2da58-df22-4faf-b561-eb326c354274"), division, 05, "AB", "NO", 19, BowlingCentre.Rossmere), new SaveMatch(new Guid("7f8cb775-fee5-4c10-b886-80629953dee8"), division, 06, "NL", "MB", 09, BowlingCentre.Rossmere), new SaveMatch(new Guid("ffcbe33b-d566-4b5d-99a1-fae50bf78e2d"), division, 06, "NO", "QC", 11, BowlingCentre.Rossmere), new SaveMatch(new Guid("16821cd4-5440-4c03-aa75-a63407c696ae"), division, 06, "SK", "BC", 15, BowlingCentre.Rossmere), new SaveMatch(new Guid("8080fd93-d8d9-4b4e-bb9b-6035574f3407"), division, 06, "AB", "SO", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("2ae33883-8304-49da-9320-32112153aaf5"), division, 07, "BC", "AB", 11, BowlingCentre.Rossmere), new SaveMatch(new Guid("36303dac-6d08-4fcd-a737-e9428a2394ed"), division, 07, "SO", "SK", 13, BowlingCentre.Rossmere), new SaveMatch(new Guid("9271b16a-af20-4af4-8d5a-7c43b038364f"), division, 07, "NO", "MB", 15, BowlingCentre.Rossmere), new SaveMatch(new Guid("a3856418-719a-4f0a-8554-58205ec77cdf"), division, 07, "QC", "NL", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("b359f528-cad8-43cf-be0d-188255d0d0c7"), division, 08, "BC", "QC", 23, BowlingCentre.Academy), new SaveMatch(new Guid("4835540c-d8d7-46c4-8896-c3aa40a81b6f"), division, 08, "SO", "MB", 25, BowlingCentre.Academy), new SaveMatch(new Guid("4af689e5-31c3-4acd-8f50-aa8669b14a14"), division, 08, "NO", "SK", 27, BowlingCentre.Academy), new SaveMatch(new Guid("ba2a3ed7-c30a-491c-899d-05737e37a7ad"), division, 08, "AB", "NL", 29, BowlingCentre.Academy), new SaveMatch(new Guid("9aa8f533-90a5-4d77-b6f0-1b1e0933465a"), division, 09, "SK", "AB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("5743bdcb-5191-48e2-ad6a-b0aba3bd8269"), division, 09, "NL", "NO", 25, BowlingCentre.Academy), new SaveMatch(new Guid("2adfb0f9-838e-438a-b7de-b8777031dc94"), division, 09, "MB", "QC", 27, BowlingCentre.Academy), new SaveMatch(new Guid("5e33f57a-5555-46d5-b02a-2278a3de85ac"), division, 09, "SO", "BC", 29, BowlingCentre.Academy), new SaveMatch(new Guid("87e46ca2-65d0-4ba6-b9d1-1ea756b293bc"), division, 10, "NO", "SO", 23, BowlingCentre.Academy), new SaveMatch(new Guid("61d1fcec-c2d7-4a99-8f40-4bf47ef2903c"), division, 10, "QC", "AB", 25, BowlingCentre.Academy), new SaveMatch(new Guid("92ab1358-30b0-41a2-bb01-c5dea7a06b0d"), division, 10, "NL", "BC", 27, BowlingCentre.Academy), new SaveMatch(new Guid("21671a94-51a3-4ebe-818c-02767d229ac7"), division, 10, "SK", "MB", 29, BowlingCentre.Academy), new SaveMatch(new Guid("e548bf2f-e878-4bd6-b804-e82673afe24a"), division, 11, "MB", "NL", 23, BowlingCentre.Academy), new SaveMatch(new Guid("5dbd2303-2c4f-413d-b6ca-dfa0ef95cdd4"), division, 11, "BC", "SK", 25, BowlingCentre.Academy), new SaveMatch(new Guid("5d29361d-ea90-46f0-8c9c-70ba86e3bdd3"), division, 11, "SO", "AB", 27, BowlingCentre.Academy), new SaveMatch(new Guid("11951172-9ec1-4b46-a466-27d5615f9889"), division, 11, "QC", "NO", 29, BowlingCentre.Academy), new SaveMatch(new Guid("cce6126e-3535-48db-90cb-2b50e9bf0a62"), division, 12, "QC", "SK", 15, BowlingCentre.Academy), new SaveMatch(new Guid("a4b32939-70e8-41ae-a59f-a9f7ceea6035"), division, 12, "SO", "NL", 17, BowlingCentre.Academy), new SaveMatch(new Guid("e332da06-d7b7-4030-9a3f-cbb971fa1455"), division, 12, "BC", "NO", 19, BowlingCentre.Academy), new SaveMatch(new Guid("cf5cfdf3-0f31-490f-bcb1-9fab377eba86"), division, 12, "AB", "MB", 21, BowlingCentre.Academy), new SaveMatch(new Guid("7ef0c7f0-7a31-45d0-a448-9b2cdbae0f88"), division, 13, "MB", "NO", 15, BowlingCentre.Academy), new SaveMatch(new Guid("0de796c7-5f21-4e78-91d0-b63f20cc97fe"), division, 13, "AB", "BC", 17, BowlingCentre.Academy), new SaveMatch(new Guid("c94dc520-1342-4f00-9645-c159e72c182d"), division, 13, "NL", "QC", 19, BowlingCentre.Academy), new SaveMatch(new Guid("8565044c-256c-4dfd-b916-e26642e87857"), division, 13, "SK", "SO", 21, BowlingCentre.Academy), new SaveMatch(new Guid("76a5f239-b508-4787-b4cb-616ef6df07dc"), division, 14, "NL", "SK", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("e52f75f3-382a-4105-aab2-b8001486bead"), division, 14, "BC", "MB", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("62cd98b2-a8ce-439b-8195-6b494c96759d"), division, 14, "SO", "QC", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("a70ff17c-64fb-4fea-b296-ff60d3002728"), division, 14, "AB", "NO", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("b465233f-5598-499d-9d37-403cfd948284"), division, 15, "QC", "MB", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("ed465244-5917-478f-8e55-9fac33840fc9"), division, 15, "AB", "SK", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("9a3a26da-8014-414e-ab5e-02cd4df15029"), division, 15, "NO", "NL", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("30a4386b-cda4-4c5a-8d14-58582453f6ff"), division, 15, "BC", "SO", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("c52bf196-a2de-44a4-a774-bb72b2129d15"), division, 16, "NO", "BC", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("c3edf7f1-bef0-474a-80ea-2373c1c22069"), division, 16, "NL", "SO", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("64875dca-79d7-4751-a7ff-86d63e8015ff"), division, 16, "MB", "AB", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("a908e129-114f-4190-8ef6-09b382fd4003"), division, 16, "SK", "QC", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("a64516ab-f01f-4de7-bc4d-a5bc506b69e6"), division, 17, "SO", "AB", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("d7f14a8e-6cb8-43f8-8566-42f5f02ee161"), division, 17, "QC", "NO", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("7eefb94b-79be-4d45-b99b-d39f4135e423"), division, 17, "SK", "BC", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("f1cb4776-1ef3-4da8-9d19-ccec2b803418"), division, 17, "NL", "MB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("255c95ba-c90b-45c1-8e58-e3d77170693e"), division, 18, "BC", "NL", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("9d9e60e2-f611-45e8-b832-7bacf32a2f1a"), division, 18, "MB", "SK", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("1a4287b4-7cf2-4b2b-bdb6-a723d192bafa"), division, 18, "SO", "NO", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("6d1a3579-ac34-4d59-bf1d-7980886173da"), division, 18, "AB", "QC", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("27915c1f-d025-47f4-bb22-1a801c0a6ea2"), division, 19, "MB", "SO", 15, BowlingCentre.Academy), new SaveMatch(new Guid("310a60fb-af79-4bb3-833e-2a4ac54e0f91"), division, 19, "SK", "NO", 17, BowlingCentre.Academy), new SaveMatch(new Guid("2eb9f68e-c92b-4d44-b593-d814e202cb72"), division, 19, "QC", "BC", 19, BowlingCentre.Academy), new SaveMatch(new Guid("a5983cec-799d-4159-bb9f-4a7f1e3c8254"), division, 19, "AB", "NL", 21, BowlingCentre.Academy), new SaveMatch(new Guid("7780cf7e-bb23-4e93-96c1-d80035200d4d"), division, 20, "BC", "AB", 15, BowlingCentre.Academy), new SaveMatch(new Guid("701b8bf4-3ab9-4700-9160-b09de79b53d4"), division, 20, "NL", "QC", 17, BowlingCentre.Academy), new SaveMatch(new Guid("c0f126e5-3e96-4cbb-b087-e2e9d8be4c59"), division, 20, "SO", "SK", 19, BowlingCentre.Academy), new SaveMatch(new Guid("8c8f3231-f486-4e6e-b310-e1595fcb2261"), division, 20, "NO", "MB", 21, BowlingCentre.Academy), new SaveMatch(new Guid("780be30f-d854-474f-83e3-467589b2a1bd"), division, 21, "SK", "NL", 15, BowlingCentre.Academy), new SaveMatch(new Guid("efeec6fe-f4ff-49ce-bd06-315ef8264aea"), division, 21, "MB", "BC", 17, BowlingCentre.Academy), new SaveMatch(new Guid("bf35c15b-8e0a-4071-8bbc-c5d1bed9a824"), division, 21, "NO", "AB", 19, BowlingCentre.Academy), new SaveMatch(new Guid("36f134db-d1a3-4af3-ada0-a09df69c82ed"), division, 21, "QC", "SO", 21, BowlingCentre.Academy) }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
public static void TournamentLadiesSingle(MessageDispatcher dispatcher) { var scheduleId = new Guid("fee09860-a9e9-4e89-86b5-7c62735f9236"); var division = "Tournament Ladies Single"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("b096ace7-ea86-4350-8238-e0175b469f33"), division, 01, "SO", "AB", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("5b1aa1c0-0e86-4dd7-a2b8-f1e6ff36e867"), division, 01, "NO", "MB", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("e9368614-9144-46c6-97cb-2a0db6320179"), division, 01, "BC", "NL", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("5a8de460-8f61-4cd1-82e9-18866c1dbb19"), division, 01, "QC", "SK", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("6559c941-45db-409d-a597-f4ccaf098d8e"), division, 02, "BC", "SK", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("a121ea1c-eeb0-4057-8094-5bf46ca33e75"), division, 02, "NL", "QC", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("1b9488bf-6f77-4d6f-85c8-5d62dca79f34"), division, 02, "MB", "SO", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("b3ac5fbc-7c44-471b-a722-e924bf022735"), division, 02, "AB", "NO", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("7296699d-bb58-48df-92b8-ae5c1d0997d0"), division, 03, "NL", "NO", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("fe7c24ad-56ad-491b-95b4-84c282b6e9ff"), division, 03, "SK", "SO", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("a7bac241-8a72-49b1-8fcb-2fc9c11cf063"), division, 03, "QC", "AB", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("0a179f36-4f78-480b-b637-8ddecaa25bb4"), division, 03, "MB", "BC", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("fa4a1443-7991-4af5-a3ff-ad11066f6176"), division, 04, "QC", "MB", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("e8f54c39-7694-4583-85e8-fff9c0fb415a"), division, 04, "AB", "BC", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("cb1ea9f5-daa1-4dc6-beef-9916008c2fd1"), division, 04, "NO", "SK", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("300c2d21-93a3-435d-a859-0d2e267896e5"), division, 04, "SO", "NL", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("e6865484-aaae-4cad-871b-1e1af1e63f8c"), division, 05, "SK", "AB", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("a73c5f70-0c15-46b2-9155-c1c173c60bc4"), division, 05, "MB", "NL", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("ff154974-27d4-4e4b-903d-701f662c1bc1"), division, 05, "SO", "QC", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("95256f2c-6f9a-4393-816e-71d27cf812ed"), division, 05, "BC", "NO", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("8b8597be-ee95-4c4f-902f-9b820e67c317"), division, 06, "NO", "SO", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("73de1f25-4e7f-4f9b-9d46-7f30758beae7"), division, 06, "BC", "QC", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("a584f54e-422f-4f42-a23b-3c4386d07798"), division, 06, "NL", "SK", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("78bdf7a4-d31d-4e03-9616-7367a66919f4"), division, 06, "AB", "MB", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("820c22c3-0240-40b2-a789-af89dfbb226d"), division, 07, "AB", "NL", 1, BowlingCentre.Rossmere), new SaveMatch(new Guid("a3651ecc-92fa-46a7-8366-18feeb416865"), division, 07, "SK", "MB", 3, BowlingCentre.Rossmere), new SaveMatch(new Guid("94825e67-fe36-4cc9-a0eb-32513ee300fe"), division, 07, "QC", "NO", 5, BowlingCentre.Rossmere), new SaveMatch(new Guid("c8363082-cc86-40bf-ac70-eeae506cda48"), division, 07, "SO", "BC", 7, BowlingCentre.Rossmere), new SaveMatch(new Guid("23933fdf-8ea7-43cc-863b-f71ffeac1203"), division, 08, "SO", "NL", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("30e67c5f-201f-4ada-8b1b-12faade4d4b4"), division, 08, "MB", "QC", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("cf52d711-d6b0-4222-a1f6-ddf33c74243e"), division, 08, "BC", "AB", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("06bf3c5d-f266-4a8b-8f86-02d1e318910f"), division, 08, "SK", "NO", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("e79857d4-8c06-451c-a6a4-0bc94e85caba"), division, 09, "SK", "BC", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("6f8587b5-0142-43bd-86f6-7d546b0521e9"), division, 09, "NO", "AB", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("479f8ee8-3148-4fa7-9051-7a4dc66f68db"), division, 09, "QC", "NL", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("84b5e32a-cc9c-4e37-9c51-6d5e5639c505"), division, 09, "SO", "MB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("bc780a72-cfb1-4215-b5a3-7885102f96dd"), division, 10, "NO", "QC", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("dc9021e9-f4d5-447c-80d5-2ff791ba4999"), division, 10, "BC", "SO", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("36313faa-8803-4c8a-9251-7ad80bbf6770"), division, 10, "MB", "SK", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("e46a43d4-4e46-4513-b227-562ab1350430"), division, 10, "NL", "AB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("2236b743-23e7-44dc-ae71-6746820b7906"), division, 11, "MB", "AB", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("8c2fd200-73a4-4002-864d-45f5b801c107"), division, 11, "SK", "NL", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("54e54f6c-0ec9-4825-9ad0-ba911745b8c5"), division, 11, "SO", "NO", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("71ef4d76-0427-425c-b36f-132b3f162c54"), division, 11, "QC", "BC", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("d542d7ea-3e8e-4813-b51e-5563ddff3d5e"), division, 12, "QC", "SO", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("ba9d9228-fff6-434f-aabd-17ecbfd42dfc"), division, 12, "NO", "BC", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("23290cc1-597e-44d1-8de7-efa2ab493dcd"), division, 12, "NL", "MB", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("445b49c2-fe34-47f5-912d-d1fc70c93eeb"), division, 12, "AB", "SK", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("6778e8a8-f77c-475f-92a3-7b924722f972"), division, 13, "NO", "NL", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("f7d73a90-f977-46d1-926d-4fcf0997cb78"), division, 13, "SO", "SK", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("4904a811-426b-475d-8a95-6aa88f8299b0"), division, 13, "AB", "QC", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("dd4e9904-7b80-4c6a-bf45-6d3209b01b92"), division, 13, "BC", "MB", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("caf977db-12c3-4348-b4b0-0fb857282e1a"), division, 14, "AB", "SO", 1, BowlingCentre.Coronation), new SaveMatch(new Guid("2e860e99-503d-469b-87ef-3756801cc74c"), division, 14, "MB", "NO", 3, BowlingCentre.Coronation), new SaveMatch(new Guid("1618953f-13f3-4485-8933-f4f477f37532"), division, 14, "NL", "BC", 5, BowlingCentre.Coronation), new SaveMatch(new Guid("93396c94-930c-4bae-b40e-7c8a11ba3cbe"), division, 14, "SK", "QC", 7, BowlingCentre.Coronation), new SaveMatch(new Guid("b46c8aa9-d665-4726-91df-ceb113fcaa8a"), division, 15, "SK", "AB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("9239e540-27a9-4ca6-aaf6-a7a1b9afd442"), division, 15, "MB", "NL", 25, BowlingCentre.Academy), new SaveMatch(new Guid("b552a8bd-291e-4072-8080-e58e7407d4fc"), division, 15, "QC", "SO", 27, BowlingCentre.Academy), new SaveMatch(new Guid("f48b7417-d0fb-4d68-a5ad-e779823fbae6"), division, 15, "BC", "NO", 29, BowlingCentre.Academy), new SaveMatch(new Guid("96582b3a-271b-49cd-932f-e71d1b5f522d"), division, 16, "SO", "BC", 23, BowlingCentre.Academy), new SaveMatch(new Guid("cc75b845-e13f-482d-b48e-9b34c6f41eb5"), division, 16, "QC", "NO", 25, BowlingCentre.Academy), new SaveMatch(new Guid("971b50c9-7a3a-4bef-a429-c8b6ae59518b"), division, 16, "MB", "SK", 27, BowlingCentre.Academy), new SaveMatch(new Guid("09e26df5-e275-4a71-87c0-6698f9a24c24"), division, 16, "NL", "AB", 29, BowlingCentre.Academy), new SaveMatch(new Guid("bd86fa80-c588-4bd5-82b1-606466d343d9"), division, 17, "NO", "MB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("d4a924cc-f285-4042-a5a6-57ef2e888d02"), division, 17, "SO", "AB", 25, BowlingCentre.Academy), new SaveMatch(new Guid("8487a7b1-eac3-489f-a8d1-ae2887eb115f"), division, 17, "BC", "NL", 27, BowlingCentre.Academy), new SaveMatch(new Guid("a0c30e3d-968a-4d95-986f-17c1e3938295"), division, 17, "SK", "QC", 29, BowlingCentre.Academy), new SaveMatch(new Guid("c898a3ec-b4c1-444b-a504-078b155f1c40"), division, 18, "NL", "SK", 23, BowlingCentre.Academy), new SaveMatch(new Guid("6ea7e219-b3e4-4a50-ab6d-9d481f19a026"), division, 18, "BC", "QC", 25, BowlingCentre.Academy), new SaveMatch(new Guid("53394cec-430c-4fef-82d8-bd3730fbd246"), division, 18, "AB", "MB", 27, BowlingCentre.Academy), new SaveMatch(new Guid("f80c6265-b30b-4dda-9aa2-3ff2cf3aac47"), division, 18, "NO", "SO", 29, BowlingCentre.Academy), new SaveMatch(new Guid("76215c4a-b57b-47b0-bd08-4bc1eb12dcb8"), division, 19, "AB", "BC", 23, BowlingCentre.Academy), new SaveMatch(new Guid("b22f1ef3-353e-4794-be1f-4a13224ebb8b"), division, 19, "SK", "NO", 25, BowlingCentre.Academy), new SaveMatch(new Guid("d8a5f84c-d8a7-4c9b-b210-e21a94725df6"), division, 19, "NL", "SO", 27, BowlingCentre.Academy), new SaveMatch(new Guid("6ca88d1a-d031-4f3b-b096-b89285dba72e"), division, 19, "QC", "MB", 29, BowlingCentre.Academy), new SaveMatch(new Guid("43e20909-84ee-4510-ace9-290fe3f8e3ca"), division, 20, "NO", "NL", 23, BowlingCentre.Academy), new SaveMatch(new Guid("0583d000-189f-41d6-ad89-4e925fcef6f6"), division, 20, "MB", "BC", 25, BowlingCentre.Academy), new SaveMatch(new Guid("7f5cdafe-bad8-4d9f-81b8-376167f01249"), division, 20, "QC", "AB", 27, BowlingCentre.Academy), new SaveMatch(new Guid("edc0854d-0399-4f53-9aa1-3fc695c37976"), division, 20, "SO", "SK", 29, BowlingCentre.Academy), new SaveMatch(new Guid("f06eb5ba-a782-4577-a4b1-9b1ba5cb7d28"), division, 21, "MB", "SO", 23, BowlingCentre.Academy), new SaveMatch(new Guid("41dbe216-b145-4132-acfa-64874c844693"), division, 21, "NL", "QC", 25, BowlingCentre.Academy), new SaveMatch(new Guid("4f217e0a-00c4-44b1-a7e9-598d15c3f6c5"), division, 21, "BC", "SK", 27, BowlingCentre.Academy), new SaveMatch(new Guid("f583f9bd-1f9c-43f7-81d3-9d52d90e760f"), division, 21, "AB", "NO", 29, BowlingCentre.Academy), }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
public static void TournamentLadies(MessageDispatcher dispatcher) { var scheduleId = new Guid("8927e212-81f6-4f42-8015-a5a3a8727819"); var division = "Tournament Ladies"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("c0ed9430-e503-467b-91e0-7413c5ee3687"), division, 01, "MB", "AB", 01, BowlingCentre.Academy), new SaveMatch(new Guid("c099a39e-c4ee-4140-9dad-607dc6e89eca"), division, 01, "NO", "BC", 05, BowlingCentre.Academy), new SaveMatch(new Guid("f6304a83-2c9e-406c-a723-b19eaa901db4"), division, 01, "NL", "SO", 09, BowlingCentre.Academy), new SaveMatch(new Guid("d7036f45-b891-4875-9fbe-a640da91c11f"), division, 02, "NL", "AB", 05, BowlingCentre.Academy), new SaveMatch(new Guid("ff03b7f0-11a9-4136-ab6a-499b55c68219"), division, 02, "SO", "MB", 07, BowlingCentre.Academy), new SaveMatch(new Guid("e00f1269-5241-4cf5-931b-c5af516dfb52"), division, 02, "SK", "NO", 09, BowlingCentre.Academy), new SaveMatch(new Guid("f082a094-13a2-47e2-a306-4a51700d782e"), division, 03, "SO", "NO", 01, BowlingCentre.Academy), new SaveMatch(new Guid("71e1f625-5fc2-4936-a58a-7689619f2390"), division, 03, "MB", "SK", 03, BowlingCentre.Academy), new SaveMatch(new Guid("6280b64b-a7e6-4916-8ee8-74e9fc7d7309"), division, 03, "BC", "NL", 07, BowlingCentre.Academy), new SaveMatch(new Guid("1cf8c661-c0f4-4022-b2e7-7b26ce30a73e"), division, 04, "NO", "NL", 03, BowlingCentre.Academy), new SaveMatch(new Guid("11cd58d8-eb12-4e73-b2ec-d4c31a80979e"), division, 04, "AB", "SK", 07, BowlingCentre.Academy), new SaveMatch(new Guid("2c7a6549-fa20-4ee8-9400-7cd614869179"), division, 04, "BC", "SO", 11, BowlingCentre.Academy), new SaveMatch(new Guid("5f87c84a-af9a-456f-a48a-b6937a440663"), division, 05, "BC", "AB", 03, BowlingCentre.Academy), new SaveMatch(new Guid("a620a305-3e9d-40c6-88fe-0b6d68520725"), division, 05, "SO", "SK", 05, BowlingCentre.Academy), new SaveMatch(new Guid("93ff18aa-ea28-4b67-bdc2-e15e4457f2ce"), division, 05, "NO", "MB", 13, BowlingCentre.Academy), new SaveMatch(new Guid("0271f181-93c2-496e-a9ac-7f49c04342f0"), division, 06, "MB", "BC", 09, BowlingCentre.Academy), new SaveMatch(new Guid("883451c0-5bc0-4fa5-bc40-c99f64ea5c24"), division, 06, "AB", "NO", 11, BowlingCentre.Academy), new SaveMatch(new Guid("26b30af0-7795-47c9-b71d-1ee62ccd3096"), division, 06, "SK", "NL", 13, BowlingCentre.Academy), new SaveMatch(new Guid("d1e9be1e-02ca-44be-9517-780643ac3111"), division, 07, "SK", "BC", 01, BowlingCentre.Academy), new SaveMatch(new Guid("eb152667-a412-4f58-a673-ef8422b62b80"), division, 07, "NL", "MB", 11, BowlingCentre.Academy), new SaveMatch(new Guid("91ae8019-5ba3-498c-8c50-f1144bdf536b"), division, 07, "AB", "SO", 13, BowlingCentre.Academy), new SaveMatch(new Guid("a2bcead0-fb2c-42a9-9b30-ceaccb1e0687"), division, 08, "NO", "SO", 15, BowlingCentre.Academy), new SaveMatch(new Guid("ea0175c3-cc5e-41b1-a016-74ac0ed403ca"), division, 08, "NL", "BC", 19, BowlingCentre.Academy), new SaveMatch(new Guid("78558724-3441-4994-a28c-c0a73074f8a5"), division, 08, "SK", "MB", 21, BowlingCentre.Academy), new SaveMatch(new Guid("cf5cb6af-3394-47f5-9eb3-093e099f1032"), division, 09, "SK", "AB", 15, BowlingCentre.Academy), new SaveMatch(new Guid("93c2a398-a53e-43a4-bf5a-9766be2edc5e"), division, 09, "NL", "NO", 17, BowlingCentre.Academy), new SaveMatch(new Guid("438e8d18-31f0-40bf-91fb-938d885c7cef"), division, 09, "SO", "BC", 21, BowlingCentre.Academy), new SaveMatch(new Guid("a6659a50-a16b-4805-9ce4-9223f16982d5"), division, 10, "MB", "SO", 17, BowlingCentre.Academy), new SaveMatch(new Guid("0c3503bb-375d-449b-9aee-36281dc1db56"), division, 10, "NO", "SK", 19, BowlingCentre.Academy), new SaveMatch(new Guid("2d5862c6-8e17-4507-8ee4-6e78114c5302"), division, 10, "NL", "AB", 21, BowlingCentre.Academy), new SaveMatch(new Guid("538a7c35-e8b2-4a88-883a-1395c6911ff0"), division, 11, "MB", "NL", 15, BowlingCentre.Academy), new SaveMatch(new Guid("efb2c962-0707-4b6f-b3ab-e4772ce60ff9"), division, 11, "BC", "SK", 17, BowlingCentre.Academy), new SaveMatch(new Guid("adc8271c-bd83-4c44-b672-2a0b49cb9188"), division, 11, "SO", "AB", 19, BowlingCentre.Academy), new SaveMatch(new Guid("858b2460-77a9-4308-a25c-d65e918a74dd"), division, 12, "AB", "MB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("dfc04d8b-76c8-4c67-8f7c-d8a29103068c"), division, 12, "BC", "NO", 25, BowlingCentre.Academy), new SaveMatch(new Guid("aebdc47d-91b5-4beb-9b60-97113573f251"), division, 12, "SO", "NL", 29, BowlingCentre.Academy), new SaveMatch(new Guid("f4e8869b-29db-4075-8c53-c94299c8e682"), division, 13, "SK", "SO", 23, BowlingCentre.Academy), new SaveMatch(new Guid("4e6ad444-339f-4bbc-a30c-ab01e2ecacba"), division, 13, "AB", "BC", 27, BowlingCentre.Academy), new SaveMatch(new Guid("14367bb9-aead-4b4d-ae89-27a619b9320a"), division, 13, "MB", "NO", 29, BowlingCentre.Academy), new SaveMatch(new Guid("26ac3e7a-911a-4817-8ccd-4be805d6b8fd"), division, 14, "SK", "NL", 03, BowlingCentre.Rossmere), new SaveMatch(new Guid("c4dd67e0-2fec-4ca7-a067-48faf3b39d3e"), division, 14, "AB", "NO", 07, BowlingCentre.Rossmere), new SaveMatch(new Guid("a39a13eb-cc27-4c2f-b832-cbda93aefac4"), division, 14, "MB", "BC", 09, BowlingCentre.Rossmere), new SaveMatch(new Guid("c02afe28-e2f7-46e9-931b-2b100bbdba85"), division, 15, "AB", "SO", 03, BowlingCentre.Rossmere), new SaveMatch(new Guid("59abcefb-926b-4b71-86b7-cb19d27cd083"), division, 15, "MB", "NL", 05, BowlingCentre.Rossmere), new SaveMatch(new Guid("6d34ed80-ae82-4608-838b-316a2555c047"), division, 15, "BC", "SK", 07, BowlingCentre.Rossmere), new SaveMatch(new Guid("0061d208-383e-4a74-9cef-571a5a1f3903"), division, 16, "NO", "MB", 03, BowlingCentre.Rossmere), new SaveMatch(new Guid("6e84c214-7554-4005-a6bc-d7e8d285b0bc"), division, 16, "BC", "AB", 05, BowlingCentre.Rossmere), new SaveMatch(new Guid("a909b872-763e-4686-b4c6-3c21c5b35972"), division, 16, "SO", "SK", 09, BowlingCentre.Rossmere), new SaveMatch(new Guid("61373b4f-c3ef-4de6-b6b1-6ea6891cb4f2"), division, 17, "SO", "NO", 15, BowlingCentre.Rossmere), new SaveMatch(new Guid("61d0603a-2f1d-4e29-8282-26d428916c49"), division, 17, "NL", "BC", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("019e4118-b027-45cc-a09c-3b1bddf2af1b"), division, 17, "SK", "MB", 19, BowlingCentre.Rossmere), new SaveMatch(new Guid("fa0b9473-1381-4da5-8682-d8909b586835"), division, 18, "BC", "SO", 13, BowlingCentre.Rossmere), new SaveMatch(new Guid("5e99bd4b-e9a8-4299-89f7-b5bebd64a688"), division, 18, "AB", "SK", 17, BowlingCentre.Rossmere), new SaveMatch(new Guid("0c38079a-129c-44b5-9d90-ac39f33dee34"), division, 18, "NO", "NL", 19, BowlingCentre.Rossmere), new SaveMatch(new Guid("5ffc5a40-2456-439b-9294-22261e41570b"), division, 19, "SO", "MB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("3720cabe-174f-4955-ba1b-282051af04f9"), division, 19, "SK", "NO", 27, BowlingCentre.Academy), new SaveMatch(new Guid("06449775-549b-4278-a0da-0f1a65e47c4b"), division, 19, "AB", "NL", 29, BowlingCentre.Academy), new SaveMatch(new Guid("c916151e-06cf-4d2a-8d50-a4f4e39388dd"), division, 20, "MB", "AB", 25, BowlingCentre.Academy), new SaveMatch(new Guid("0ec9ec5b-1d3b-444d-b85a-3b483f6a1db4"), division, 20, "NL", "SO", 27, BowlingCentre.Academy), new SaveMatch(new Guid("c3eb2c5a-bab1-4d8b-9015-25a1f8ba49a6"), division, 20, "NO", "BC", 29, BowlingCentre.Academy), new SaveMatch(new Guid("bf750114-9f59-4743-82ee-a8d242b47025"), division, 21, "NO", "AB", 23, BowlingCentre.Academy), new SaveMatch(new Guid("cabe33a7-c8a3-420b-a1c2-df08e5b29e17"), division, 21, "NL", "SK", 25, BowlingCentre.Academy), new SaveMatch(new Guid("7323548c-ea07-42fe-b3a1-44a784a84889"), division, 21, "BC", "MB", 27, BowlingCentre.Academy), }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
public async Task When_OTAA_Join_Then_Sends_Upstream_DirectMethod_Should_Send_Downstream(string deviceGatewayID) { var simDevice = new SimulatedDevice(TestDeviceInfo.CreateOTAADevice(1, deviceClassType: 'c', gatewayID: deviceGatewayID)); LoRaDeviceClient.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(simDevice.CreateOTAATwin()); AppSessionKey? savedAppSKey = null; NetworkSessionKey?savedNwkSKey = null; var savedDevAddr = string.Empty; LoRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true) .Callback <TwinCollection, CancellationToken>((t, _) => { savedAppSKey = AppSessionKey.Parse(t[TwinProperty.AppSKey].Value); savedNwkSKey = NetworkSessionKey.Parse(t[TwinProperty.NwkSKey].Value); savedDevAddr = t[TwinProperty.DevAddr]; }); LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .ReturnsAsync(true); LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync((Message)null); if (deviceGatewayID == null) { LoRaDeviceApi.Setup(x => x.ExecuteFunctionBundlerAsync(simDevice.DevEUI, It.IsNotNull <FunctionBundlerRequest>())) .ReturnsAsync(new FunctionBundlerResult()); } LoRaDeviceApi.Setup(x => x.SearchAndLockForJoinAsync(ServerConfiguration.GatewayID, simDevice.DevEUI, It.IsAny <DevNonce>())) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(simDevice.DevAddr, simDevice.DevEUI, "123").AsList())); using var cache = NewMemoryCache(); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, DeviceCache); using var messageDispatcher = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var payloadata = simDevice.CreateJoinRequest(); using var joinRequest = CreateWaitableRequest(payloadata); joinRequest.SetStationEui(new StationEui(ulong.MaxValue)); messageDispatcher.DispatchRequest(joinRequest); Assert.True(await joinRequest.WaitCompleteAsync()); Assert.True(joinRequest.ProcessingSucceeded); Assert.NotNull(savedAppSKey); Assert.NotNull(savedNwkSKey); Assert.NotEmpty(savedDevAddr); simDevice.SetupJoin(savedAppSKey.Value, savedNwkSKey.Value, DevAddr.Parse(savedDevAddr)); using var request = CreateWaitableRequest(simDevice.CreateUnconfirmedDataUpMessage("1")); request.SetStationEui(new StationEui(ulong.MaxValue)); messageDispatcher.DispatchRequest(request); Assert.True(await request.WaitCompleteAsync()); Assert.True(request.ProcessingSucceeded); var classCSender = new DefaultClassCDevicesMessageSender( ServerConfiguration, deviceRegistry, DownstreamMessageSender, FrameCounterUpdateStrategyProvider, new TestOutputLogger <DefaultClassCDevicesMessageSender>(this.testOutputHelper), TestMeter.Instance); var c2d = new ReceivedLoRaCloudToDeviceMessage() { DevEUI = simDevice.DevEUI, MessageId = Guid.NewGuid().ToString(), Payload = "aaaa", Fport = FramePorts.App14, }; if (string.IsNullOrEmpty(deviceGatewayID)) { LoRaDeviceApi.Setup(x => x.NextFCntDownAsync(simDevice.DevEUI, simDevice.FrmCntDown, 0, ServerConfiguration.GatewayID)) .ReturnsAsync((ushort)(simDevice.FrmCntDown + 1)); } Assert.True(await classCSender.SendAsync(c2d)); Assert.Equal(2, DownstreamMessageSender.DownlinkMessages.Count); var downstreamMsg = DownstreamMessageSender.DownlinkMessages[1]; TestLogger.Log($"appSKey: {simDevice.AppSKey}, nwkSKey: {simDevice.NwkSKey}"); var downstreamPayloadBytes = downstreamMsg.Data; var downstreamPayload = new LoRaPayloadData(downstreamPayloadBytes); Assert.Equal(1, downstreamPayload.Fcnt); Assert.Equal(c2d.Fport, downstreamPayload.Fport); Assert.Equal(downstreamPayload.DevAddr, DevAddr.Parse(savedDevAddr)); var decryptedPayload = downstreamPayload.GetDecryptedPayload(simDevice.AppSKey.Value); Assert.Equal(c2d.Payload, Encoding.UTF8.GetString(decryptedPayload)); LoRaDeviceApi.VerifyAll(); LoRaDeviceClient.VerifyAll(); }
public async Task When_Joining_Should_Save_Region_And_Preferred_Gateway( [CombinatorialValues(null, ServerGatewayID)] string deviceGatewayID, [CombinatorialValues(null, ServerGatewayID, "another-gateway")] string initialPreferredGatewayID, [CombinatorialValues(null, LoRaRegionType.EU868, LoRaRegionType.US915)] LoRaRegionType?initialLoRaRegion) { var simDevice = new SimulatedDevice(TestDeviceInfo.CreateOTAADevice(1, deviceClassType: 'c', gatewayID: deviceGatewayID)); var customReportedProperties = new Dictionary <string, object>(); // reported: { 'PreferredGateway': '' } -> if device is for multiple gateways and one initial was defined if (string.IsNullOrEmpty(deviceGatewayID) && !string.IsNullOrEmpty(initialPreferredGatewayID)) { customReportedProperties[TwinProperty.PreferredGatewayID] = initialPreferredGatewayID; } if (initialLoRaRegion.HasValue) { customReportedProperties[TwinProperty.Region] = initialLoRaRegion.Value.ToString(); } LoRaDeviceClient.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(simDevice.CreateOTAATwin(reportedProperties: customReportedProperties)); var shouldSavePreferredGateway = string.IsNullOrEmpty(deviceGatewayID) && initialPreferredGatewayID != ServerGatewayID; var shouldSaveRegion = !initialLoRaRegion.HasValue || initialLoRaRegion.Value != LoRaRegionType.EU868; var savedAppSKey = string.Empty; var savedNwkSKey = string.Empty; var savedDevAddr = string.Empty; TwinCollection actualTwinCollection = null; LoRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true) .Callback <TwinCollection, CancellationToken>((t, _) => { savedAppSKey = t[TwinProperty.AppSKey]; savedNwkSKey = t[TwinProperty.NwkSKey]; savedDevAddr = t[TwinProperty.DevAddr]; actualTwinCollection = t; }); LoRaDeviceApi.Setup(x => x.SearchAndLockForJoinAsync(ServerConfiguration.GatewayID, simDevice.DevEUI, It.IsAny <DevNonce>())) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(simDevice.DevAddr, simDevice.DevEUI, "123").AsList())); using var cache = NewMemoryCache(); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, DeviceCache); using var messageDispatcher = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var joinPayload = simDevice.CreateJoinRequest(); using var joinRequest = CreateWaitableRequest(joinPayload); messageDispatcher.DispatchRequest(joinRequest); Assert.True(await joinRequest.WaitCompleteAsync()); Assert.True(joinRequest.ProcessingSucceeded); Assert.NotEmpty(savedAppSKey); Assert.NotEmpty(savedNwkSKey); Assert.NotEmpty(savedDevAddr); if (shouldSaveRegion) { Assert.Equal(LoRaRegionType.EU868.ToString(), actualTwinCollection[TwinProperty.Region].Value as string); } else { Assert.False(actualTwinCollection.Contains(TwinProperty.Region)); } // Only save preferred gateway if device does not have one assigned if (shouldSavePreferredGateway) { Assert.Equal(ServerConfiguration.GatewayID, actualTwinCollection[TwinProperty.PreferredGatewayID].Value as string); } else { Assert.False(actualTwinCollection.Contains(TwinProperty.PreferredGatewayID)); } Assert.True(DeviceCache.TryGetByDevEui(simDevice.DevEUI, out var loRaDevice)); Assert.Equal(LoRaDeviceClassType.C, loRaDevice.ClassType); if (string.IsNullOrEmpty(simDevice.LoRaDevice.GatewayID)) { Assert.Equal(ServerConfiguration.GatewayID, loRaDevice.PreferredGatewayID); } else { Assert.Empty(loRaDevice.PreferredGatewayID); } Assert.Equal(LoRaRegionType.EU868, loRaDevice.LoRaRegion); LoRaDeviceApi.VerifyAll(); LoRaDeviceClient.VerifyAll(); }
public override void OnEnable() { Debug.Log("Click_show_hideDemo OnEnable !"); MessageDispatcher.AddListener(PointEventType.ToString(), GetPointEventType); MessageDispatcher.AddListener(WsMessageType.RecieveCChangeObj.ToString(), RecieveCChangeObj); }
void HandleGetPointedObj() { clickedName = ClickedObj.name + "has clicked !"; if (mStaticThings.I == null) { return; } WsChangeInfo wsinfo = new WsChangeInfo() { id = mStaticThings.I.mAvatarID, name = "InfoLog", a = clickedName, b = InfoColor.green.ToString(), c = 5.ToString(), }; MessageDispatcher.SendMessage(this, VrDispMessageType.SendInfolog.ToString(), wsinfo, 0); int _id = -1; if (ClickedObj == null || ClickedObj.Equals(null)) { _id = ClickObjs.FindIndex(x => x == null || x.Equals(null)); } else { _id = ClickObjs.IndexOf(ClickedObj); } var _iscontained = _id != -1; if (!_iscontained) { return; } if (_id >= ShowObjs.Count) { return; } showItem = ShowObjs[_id]; showItemName = showItem.name; if (showItem.gameObject.activeInHierarchy) { WsCChangeInfo wsinfo1 = new WsCChangeInfo() { a = "hideitem", b = showItemName, c = string.Empty, d = string.Empty, e = string.Empty, f = string.Empty, g = string.Empty, }; MessageDispatcher.SendMessage(this, WsMessageType.SendCChangeObj.ToString(), wsinfo1, 0); } else { WsCChangeInfo wsinfo1 = new WsCChangeInfo() { a = "showitem", b = showItemName, c = string.Empty, d = string.Empty, e = string.Empty, f = string.Empty, g = string.Empty, }; MessageDispatcher.SendMessage(this, WsMessageType.SendCChangeObj.ToString(), wsinfo1, 0); } }
public override void OnExit() { MessageDispatcher.RemoveListener(PointEventType.ToString(), GetPointEventType); }
public override void OnExit() { MessageDispatcher.RemoveListener(VrDispMessageType.GetLocalCacheFile.ToString(), GetCacheFile); }
public async void ThrowingCallbackReturnsErrorResponse() { var dispatcher = new MessageDispatcher(); dispatcher.RegisterMethod("testMethod", (@params) => { throw new Exception("ERROR"); }); var request = new JObject( new JProperty("id", "ID"), new JProperty("method", "testMethod")); var response = await dispatcher.DispatchAsync(request); var error = (JObject)response["error"]; Assert.Equal(-32603, (int)error["code"]); Assert.Equal("ERROR", (string)error["message"]); Assert.Contains(System.Reflection.MethodInfo.GetCurrentMethod().Name, (string)error["data"]); }
public override void OnDisable() { MessageDispatcher.RemoveListener(PointEventType.ToString(), GetPointEventType); MessageDispatcher.RemoveListener(WsMessageType.RecieveCChangeObj.ToString(), RecieveCChangeObj); }
public static void TeachingMen(MessageDispatcher dispatcher) { var scheduleId = new Guid("b47282f0-b6a2-4dc0-aee1-7a99d5e0ad68"); var division = "Teaching Men"; var commands = new List<SaveMatch> { new SaveMatch(new Guid("1541e3a3-d08d-41c4-a749-ad266f662d3a"), division, 01, "MB", "NO", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("36eaa554-b775-429a-954c-e4932eddcf40"), division, 01, "SK", "AB", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("379329cc-fb8d-4dfd-9376-934e464c708c"), division, 01, "BC", "SO", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("6de17e83-9310-4e9f-831e-037b0920efd6"), division, 01, "QC", "NL", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("07e3dad9-39a1-4e39-bf43-3a2f762c522e"), division, 02, "BC", "QC", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("6a2de1b7-c42b-4abe-9549-48d4fc03d58a"), division, 02, "SO", "NL", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("043d9a27-de80-4838-81c5-43acf474b878"), division, 02, "AB", "MB", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("75ba7d7b-b526-47e3-9e58-4cf3d45d748a"), division, 02, "NO", "SK", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("a3ccafac-9626-4d3a-b229-752cdccda4d1"), division, 03, "SO", "SK", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("c26eec29-3bf5-4bdc-8614-0ae64caf9e28"), division, 03, "QC", "MB", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("8a620190-1d27-4b93-9028-626f7d27510c"), division, 03, "NL", "NO", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("54ed9bd9-e599-4c23-897c-cc2e86d25c21"), division, 03, "AB", "BC", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("57b4fa75-2d2f-4f36-b897-cd946abe0105"), division, 04, "NL", "AB", 23, BowlingCentre.Academy, true), new SaveMatch(new Guid("367fa605-ef12-4e2f-bb8d-b4fb0a142ce5"), division, 04, "NO", "BC", 25, BowlingCentre.Academy, true), new SaveMatch(new Guid("946b0016-57d6-463c-9b09-acb064ccf387"), division, 04, "SK", "QC", 27, BowlingCentre.Academy, true), new SaveMatch(new Guid("508e1669-0af7-4e73-82e4-8f72763fc4be"), division, 04, "MB", "SO", 29, BowlingCentre.Academy, true), new SaveMatch(new Guid("8297ae0f-d497-401c-851d-310ad5adbe2e"), division, 05, "QC", "NO", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("3bdee99d-479d-4c6f-99df-3b4cf079f7ba"), division, 05, "AB", "SO", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("aea11ef3-88bd-4767-a3ce-a7eccf1d6b86"), division, 05, "MB", "NL", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("de7baca2-adce-40ef-b378-8eb5bc11793e"), division, 05, "BC", "SK", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("43260892-d0d5-41ed-b0d5-6f8531df9724"), division, 06, "NL", "BC", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("dbeef02a-5c83-41f8-8439-8b80fef7c7fe"), division, 06, "SK", "MB", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("ef2e827f-5931-4d02-98ea-9fbb121a40d7"), division, 06, "SO", "QC", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("ff69b1c5-3519-42c2-804a-2df8137e638b"), division, 06, "NO", "AB", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("5fa6e3fa-2b98-4d7c-8d10-5f7e243e6e4a"), division, 07, "NO", "SO", 15, BowlingCentre.Academy, true), new SaveMatch(new Guid("90de26fa-85a3-4253-9fd5-b76fa74ffde5"), division, 07, "AB", "QC", 17, BowlingCentre.Academy, true), new SaveMatch(new Guid("6baf6917-f3e4-49e1-9464-16133d89ce03"), division, 07, "NL", "SK", 19, BowlingCentre.Academy, true), new SaveMatch(new Guid("40bd8da6-c37d-439a-8d85-2988d6440e32"), division, 07, "BC", "MB", 21, BowlingCentre.Academy, true), new SaveMatch(new Guid("6537303c-a02b-43d2-9236-a7582fe67b35"), division, 08, "BC", "AB", 3, BowlingCentre.Academy, true), new SaveMatch(new Guid("38376d6c-bf37-4078-93a0-909dd24993ad"), division, 08, "NO", "NL", 5, BowlingCentre.Academy, true), new SaveMatch(new Guid("21d3d356-12fa-41c2-bf15-6bdbc2a27126"), division, 08, "MB", "QC", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("4fcf5522-5a19-4888-967a-d0d86b5c7cc0"), division, 08, "SK", "SO", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("6358abb0-2996-424f-9bd7-1e3be4bc9f5f"), division, 09, "NO", "SK", 3, BowlingCentre.Academy, true), new SaveMatch(new Guid("435e0a64-9c3e-4c3a-9aa8-1137371600f6"), division, 09, "AB", "MB", 7, BowlingCentre.Academy, true), new SaveMatch(new Guid("1e17d1bd-4fb6-4c10-bdd2-5d4a35411d98"), division, 09, "SO", "NL", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("e54fc7e3-a182-4070-8942-2d772c563e7d"), division, 09, "BC", "QC", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("916527bc-74bd-47a5-b6f8-4078b6504a3c"), division, 10, "QC", "NL", 3, BowlingCentre.Academy, true), new SaveMatch(new Guid("df42bc96-c8f3-4882-a2fd-bb2d86d07b70"), division, 10, "SO", "BC", 5, BowlingCentre.Academy, true), new SaveMatch(new Guid("52a13b0f-fa19-479c-b0a1-78407e4bf2ef"), division, 10, "SK", "AB", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("783dfb45-8e2b-419f-8231-67f346b8be30"), division, 10, "MB", "NO", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("e8ecea6a-5f06-4205-b1e6-fb33b2b6d15b"), division, 11, "SO", "MB", 3, BowlingCentre.Academy, true), new SaveMatch(new Guid("fc6f0752-33f9-4a9b-85ab-300452c34445"), division, 11, "NO", "BC", 7, BowlingCentre.Academy, true), new SaveMatch(new Guid("3654abb0-9f26-420e-800f-d9b7431d336b"), division, 11, "SK", "QC", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("746bb43f-12b1-4261-b527-f86718a36811"), division, 11, "NL", "AB", 13, BowlingCentre.Academy, true), new SaveMatch(new Guid("678ee20a-49cf-44da-bcd1-cdb280fa4352"), division, 12, "QC", "AB", 5, BowlingCentre.Academy, true), new SaveMatch(new Guid("5f5aeb0b-7cc7-4cae-bfef-fdf154772693"), division, 12, "NL", "SK", 7, BowlingCentre.Academy, true), new SaveMatch(new Guid("a310c35f-eb01-4fd8-bfcf-24816a452218"), division, 12, "NO", "SO", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("39949ffc-8ee9-4fd1-9810-295ecb82e9df"), division, 12, "MB", "BC", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("bb3271db-8c52-474a-9e16-f253816605e3"), division, 13, "MB", "SK", 5, BowlingCentre.Academy, true), new SaveMatch(new Guid("df2472d3-90b1-4722-b9e2-ab8f11bdaca1"), division, 13, "QC", "SO", 7, BowlingCentre.Academy, true), new SaveMatch(new Guid("3c2f1ae9-6d83-4d7a-8194-efa610b8b0eb"), division, 13, "BC", "NL", 09, BowlingCentre.Academy, true), new SaveMatch(new Guid("e8c25294-45c3-4e8a-bfd9-88dac22f7c32"), division, 13, "AB", "NO", 11, BowlingCentre.Academy, true), new SaveMatch(new Guid("9cf6020a-303c-4ead-ae4c-a3db3e0583f9"), division, 14, "NO", "QC", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("21e6280d-10c5-43ee-8de7-6b9500ba1cf4"), division, 14, "NL", "MB", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("24dc14f2-0ca5-4bcd-9b1d-c7dbb129f13d"), division, 14, "SO", "AB", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("508250f3-2129-4efd-b745-01ad694ceaed"), division, 14, "SK", "BC", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("8de5459f-dbfe-495b-9819-367dacfc223c"), division, 15, "SO", "MB", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("1e1848bf-0538-4e67-9f84-175972d2d512"), division, 15, "QC", "SK", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("c57c1ea6-1290-4ac1-a672-9109885f9bd3"), division, 15, "BC", "NO", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("7a787380-3898-43ff-87c8-aa3b37ff61af"), division, 15, "AB", "NL", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("80ceefba-1dfd-4a54-b7b3-d4fcd2b9d59d"), division, 16, "AB", "SK", 13, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("4659c6aa-6e53-4bad-b59a-f76e4980a5d0"), division, 16, "BC", "SO", 15, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("5c2d8564-2bf1-4946-9559-915ab2bcda4e"), division, 16, "NL", "QC", 17, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("69fdbaab-427c-4052-b046-9724700b8f13"), division, 16, "NO", "MB", 19, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("9c7d6f00-08d3-49d4-80a3-1b8b90d112be"), division, 17, "NL", "SO", 1, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("3d98f3f7-b1b4-4981-ba72-69a5a022ed66"), division, 17, "SK", "NO", 3, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("b3a34a23-8b54-4206-81db-1c2039708abf"), division, 17, "QC", "BC", 5, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("1cc21500-5d9c-40bb-85f8-2f641aadc057"), division, 17, "MB", "AB", 7, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("4a359adf-f7f6-4aa9-87b9-99cad7635793"), division, 18, "QC", "AB", 3, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("cbdebfec-276b-43c7-a931-6c009c7c700f"), division, 18, "SO", "NO", 5, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("863e89d2-53bb-4345-b84b-f4fe809a2857"), division, 18, "SK", "NL", 7, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("d8575789-82a1-4f84-9177-bdeb795786b1"), division, 18, "MB", "BC", 9, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("e3cb377c-afd3-41cd-bc26-f002bac1d8e2"), division, 19, "NO", "AB", 1, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("42ab9d40-8066-4aea-977b-5174b68b4ad8"), division, 19, "SK", "MB", 5, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("8d75384e-a734-4811-bd6b-226125b3d799"), division, 19, "SO", "QC", 7, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("4e1d446a-5e1c-4e1f-827e-5e58e94b9752"), division, 19, "NL", "BC", 9, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("b3963fde-c4f6-4f4a-906b-7c69f5101fae"), division, 20, "QC", "MB", 1, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("b4712c0c-3d18-4f09-8a0c-a21da8dc1654"), division, 20, "NL", "NO", 5, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("719b3ac0-5837-42cb-8538-ffda79291225"), division, 20, "AB", "BC", 7, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("4cf70eff-b56e-4ec9-b938-ef2fa8242301"), division, 20, "SK", "SO", 9, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("e39d4df1-c171-4b97-a6b8-f5ca46a4b5c9"), division, 21, "BC", "SK", 1, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("2460fd8d-4542-44d2-8d08-6157a5449b63"), division, 21, "MB", "NL", 3, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("2268556f-a3cd-44b3-afaf-341fa901e7ac"), division, 21, "AB", "SO", 5, BowlingCentre.Rossmere, true), new SaveMatch(new Guid("5de7e183-16d3-400d-99d2-8b2713b1ef18"), division, 21, "QC", "NO", 9, BowlingCentre.Rossmere, true), }; foreach (var command in commands) try { dispatcher.SendCommand(command); } catch (MBACNationals.Scores.MatchAlreadyCreated e) { } }
// Code that runs on entering the state. public override void OnEnter() { MessageDispatcher.AddListener(PointEventType.ToString(), GetPointEventType); }
private void InitInstance () { entityManager = new EntityManager (); messageDispatcher = new MessageDispatcher (); }
public ScoresCommandHandlers(ICommandQueries commandQueries, MessageDispatcher dispatcher) { CommandQueries = commandQueries; _dispatcher = dispatcher; }
string[] excludes = new [] { "manager" }; // won't include targets that contain these strings public void Init (MessageDispatcher dispatcher) { #if SHOW_DEBUG_INFO dispatcher.onUpdateListeners += OnUpdateListeners; #endif }
private async Task <List <WaitableLoRaRequest> > SendMessages(SimulatedDevice device, MessageDispatcher dispatcher, uint payloadInitialFcnt, int delayBetweenMessages = 1000, int messagePerDeviceCount = 5) { var requests = new List <WaitableLoRaRequest>(); for (uint i = 0; i < messagePerDeviceCount; ++i) { var payload = device.CreateUnconfirmedDataUpMessage((i + 1).ToString(CultureInfo.InvariantCulture), fcnt: payloadInitialFcnt + i); var req = CreateWaitableRequest(payload); dispatcher.DispatchRequest(req); requests.Add(req); await Task.Delay(delayBetweenMessages); } return(requests); }
public static void Setup() { ReadModelFolder = HttpContext.Current.Server.MapPath("~/App_Data/ReadModels/"); Dispatcher = new MessageDispatcher(new SqlEventStore(Properties.Settings.Default.DefaultConnection)); Dispatcher.ScanInstance(new ParticipantCommandHandlers(Dispatcher)); Dispatcher.ScanInstance(new ContingentCommandHandlers()); Dispatcher.ScanInstance(new ScoresCommandHandlers(Dispatcher)); ParticipantQueries = new ParticipantQueries(ReadModelFolder); Dispatcher.ScanInstance(ParticipantQueries); ParticipantProfileQueries = new ParticipantProfileQueries(ReadModelFolder); Dispatcher.ScanInstance(ParticipantProfileQueries); ContingentQueries = new ContingentQueries(ReadModelFolder); Dispatcher.ScanInstance(ContingentQueries); ContingentViewQueries = new ContingentViewQueries(ReadModelFolder); Dispatcher.ScanInstance(ContingentViewQueries); ContingentTravelPlanQueries = new ContingentTravelPlanQueries(ReadModelFolder); Dispatcher.ScanInstance(ContingentTravelPlanQueries); ContingentPracticePlanQueries = new ContingentPracticePlanQueries(ReadModelFolder); Dispatcher.ScanInstance(ContingentPracticePlanQueries); ContingentEventHistoryQueries = new ContingentEventHistoryQueries(ReadModelFolder); Dispatcher.ScanInstance(ContingentEventHistoryQueries); ReservationQueries = new ReservationQueries(ReadModelFolder); Dispatcher.ScanInstance(ReservationQueries); ScheduleQueries = new ScheduleQueries(ReadModelFolder); Dispatcher.ScanInstance(ScheduleQueries); MatchQueries = new MatchQueries(ReadModelFolder); Dispatcher.ScanInstance(MatchQueries); StandingQueries = new StandingQueries(ReadModelFolder); Dispatcher.ScanInstance(StandingQueries); HighScoreQueries = new HighScoreQueries(ReadModelFolder); Dispatcher.ScanInstance(HighScoreQueries); ParticipantScoreQueries = new ParticipantScoreQueries(ReadModelFolder); Dispatcher.ScanInstance(ParticipantScoreQueries); TeamScoreQueries = new TeamScoreQueries(ReadModelFolder); Dispatcher.ScanInstance(TeamScoreQueries); if (!Directory.Exists(ReadModelFolder)) { RebuildReadModels(); } }
public async Task When_Getting_C2D_Message_Fails_To_Resolve_Fcnt_Down_Should_Drop_Message_And_Return_Null() { const uint initialFcntDown = 5; const uint initialFcntUp = 21; const uint payloadFcnt = 23; var simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(1, gatewayID: null)); simulatedDevice.FrmCntUp = initialFcntUp; simulatedDevice.FrmCntDown = initialFcntDown; var devEUI = simulatedDevice.LoRaDevice.DeviceID; var devAddr = simulatedDevice.LoRaDevice.DevAddr; // message will be sent this.LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .ReturnsAsync(true); var c2dMessage = new ReceivedLoRaCloudToDeviceMessage() { Fport = 1 }; var cloudToDeviceMessage = c2dMessage.CreateMessage(); // C2D message will be retrieved this.LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsAny <TimeSpan>())) .ReturnsAsync(cloudToDeviceMessage); // C2D message will be abandonned this.LoRaDeviceClient.Setup(x => x.AbandonAsync(cloudToDeviceMessage)) .ReturnsAsync(true); // getting the fcnt down will return 0! this.LoRaDeviceApi.Setup(x => x.NextFCntDownAsync(devEUI, initialFcntDown, payloadFcnt, this.ServerConfiguration.GatewayID)) .ReturnsAsync((ushort)0); var cachedDevice = this.CreateLoRaDevice(simulatedDevice); var deviceRegistry = new LoRaDeviceRegistry(this.ServerConfiguration, this.NewNonEmptyCache(cachedDevice), this.LoRaDeviceApi.Object, this.LoRaDeviceFactory); // Send to message processor var messageDispatcher = new MessageDispatcher( this.ServerConfiguration, deviceRegistry, this.FrameCounterUpdateStrategyProvider); // sends unconfirmed message var unconfirmedMessagePayload = simulatedDevice.CreateUnconfirmedDataUpMessage("hello", fcnt: payloadFcnt); var rxpk = unconfirmedMessagePayload.SerializeUplink(simulatedDevice.AppSKey, simulatedDevice.NwkSKey).Rxpk[0]; var unconfirmedRequest = this.CreateWaitableRequest(rxpk); messageDispatcher.DispatchRequest(unconfirmedRequest); Assert.True(await unconfirmedRequest.WaitCompleteAsync()); Assert.Null(unconfirmedRequest.ResponseDownlink); var cachedDevices = deviceRegistry.InternalGetCachedDevicesForDevAddr(simulatedDevice.DevAddr); Assert.True(cachedDevices.TryGetValue(devEUI, out var loRaDevice)); // fcnt down did not change Assert.Equal(initialFcntDown, loRaDevice.FCntDown); // fcnt up changed Assert.Equal(unconfirmedMessagePayload.GetFcnt(), loRaDevice.FCntUp); this.LoRaDeviceClient.Verify(x => x.ReceiveAsync(It.IsAny <TimeSpan>()), Times.Once()); this.LoRaDeviceClient.Verify(x => x.AbandonAsync(It.IsAny <Message>()), Times.Once()); this.LoRaDeviceClient.VerifyAll(); this.LoRaDeviceApi.VerifyAll(); }
private void Start() { MessageDispatcher.AddListener(this); inventory = CharacterManager.Instance.player.GetComponent <InventoryManager>().dropedInventory; }
public static MessageDispatcher globalInstance() { if(GlobalInstance == null)GlobalInstance = new MessageDispatcher(); return GlobalInstance; }
public override void Init() { base.Init(); MessageDispatcher.AddListener("UpdateCarAmount", UpdateViewAmount); }
void OnDestroy() { MessageDispatcher.RemoveListener("FREEZE", OnFreeze); }
public void OnDestroy() { MessageDispatcher.RemoveObserver(ShowDeployAreas, Constants.MessageType.ShowDeployAreas); MessageDispatcher.RemoveObserver(CloseDeployAreas, Constants.MessageType.CloseDeployAreas); }
public async Task Unconfirmed_Cloud_To_Device_From_Decoder_Should_Call_ClassC_Message_Sender() { const uint PayloadFcnt = 10; const uint InitialDeviceFcntUp = 9; const uint InitialDeviceFcntDown = 20; var devEui = new DevEui(2); var simulatedDevice = new SimulatedDevice( TestDeviceInfo.CreateABPDevice(1, gatewayID: ServerConfiguration.GatewayID), frmCntUp: InitialDeviceFcntUp, frmCntDown: InitialDeviceFcntDown); var loraDevice = CreateLoRaDevice(simulatedDevice); LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .ReturnsAsync(true); LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsAny <TimeSpan>())) .ReturnsAsync((Message)null); var decoderResult = new DecodePayloadResult("1") { CloudToDeviceMessage = new ReceivedLoRaCloudToDeviceMessage() { Fport = FramePorts.App1, MessageId = "123", Payload = "12", DevEUI = devEui, }, }; var payloadDecoder = new Mock <ILoRaPayloadDecoder>(MockBehavior.Strict); payloadDecoder.Setup(x => x.DecodeMessageAsync(simulatedDevice.DevEUI, It.IsNotNull <byte[]>(), FramePorts.App1, It.IsAny <string>())) .ReturnsAsync(decoderResult); PayloadDecoder.SetDecoder(payloadDecoder.Object); using var cache = EmptyMemoryCache(); using var loraDeviceCache = CreateDeviceCache(loraDevice); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, loraDeviceCache); using var c2dMessageSent = new SemaphoreSlim(0); var classCMessageSender = new Mock <IClassCDeviceMessageSender>(MockBehavior.Strict); classCMessageSender.Setup(x => x.SendAsync(It.Is <IReceivedLoRaCloudToDeviceMessage>(m => !m.Confirmed && m.DevEUI == devEui), It.IsAny <CancellationToken>())) .ReturnsAsync(true) .Callback <IReceivedLoRaCloudToDeviceMessage, CancellationToken>((m, _) => c2dMessageSent.Release()); RequestHandlerImplementation.SetClassCMessageSender(classCMessageSender.Object); // Send to message processor using var messageProcessor = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var payload = simulatedDevice.CreateUnconfirmedDataUpMessage("1234", fcnt: PayloadFcnt); using var request = CreateWaitableRequest(payload); messageProcessor.DispatchRequest(request); Assert.True(await request.WaitCompleteAsync()); // Expectations // 1. Message was sent to IoT Hub LoRaDeviceClient.VerifyAll(); LoRaDeviceApi.VerifyAll(); // 2. No downstream message for the current device is sent Assert.Null(request.ResponseDownlink); Assert.True(request.ProcessingSucceeded); // 4. Frame counter up was updated Assert.Equal(PayloadFcnt, loraDevice.FCntUp); // 5. Frame counter down is unchanged Assert.Equal(InitialDeviceFcntDown, loraDevice.FCntDown); // 6. Frame count has pending changes Assert.True(loraDevice.HasFrameCountChanges); // Ensure the message was sent Assert.True(await c2dMessageSent.WaitAsync(10 * 1000)); payloadDecoder.VerifyAll(); classCMessageSender.VerifyAll(); }
/// <summary> /// Starts listening and dispatching messages from components. /// </summary> public void Start() { LogServerInfo(); var md = new MessageDispatcher(_listeningPort, _componentTimeout); md.BeginDispatching(); }
public async Task When_Processing_Data_Request_Should_Compute_Preferred_Gateway_And_Region( [CombinatorialValues(null, ServerGatewayID)] string deviceGatewayID, [CombinatorialValues(null, ServerGatewayID, "another-gateway")] string initialPreferredGatewayID, [CombinatorialValues(ServerGatewayID, "another-gateway")] string preferredGatewayID, [CombinatorialValues(null, LoRaRegionType.EU868, LoRaRegionType.US915)] LoRaRegionType?initialLoRaRegion) { const uint PayloadFcnt = 10; const uint InitialDeviceFcntUp = 9; const uint InitialDeviceFcntDown = 20; var simulatedDevice = new SimulatedDevice( TestDeviceInfo.CreateABPDevice(1, gatewayID: deviceGatewayID, deviceClassType: 'c'), frmCntUp: InitialDeviceFcntUp, frmCntDown: InitialDeviceFcntDown); var loraDevice = CreateLoRaDevice(simulatedDevice); loraDevice.UpdatePreferredGatewayID(initialPreferredGatewayID, acceptChanges: true); if (initialLoRaRegion.HasValue) { loraDevice.UpdateRegion(initialLoRaRegion.Value, acceptChanges: true); } var shouldSavePreferredGateway = string.IsNullOrEmpty(deviceGatewayID) && initialPreferredGatewayID != preferredGatewayID && preferredGatewayID == ServerGatewayID; var shouldSaveRegion = (!initialLoRaRegion.HasValue || initialLoRaRegion.Value != LoRaRegionType.EU868) && (preferredGatewayID == ServerGatewayID || deviceGatewayID != null); var bundlerResult = new FunctionBundlerResult() { PreferredGatewayResult = new PreferredGatewayResult() { DevEUI = simulatedDevice.DevEUI, PreferredGatewayID = preferredGatewayID, CurrentFcntUp = PayloadFcnt, RequestFcntUp = PayloadFcnt, } }; if (string.IsNullOrEmpty(deviceGatewayID)) { LoRaDeviceApi.Setup(x => x.ExecuteFunctionBundlerAsync(simulatedDevice.DevEUI, It.Is((FunctionBundlerRequest r) => r.ClientFCntUp == PayloadFcnt && r.GatewayId == ServerGatewayID && r.FunctionItems == FunctionBundlerItemType.PreferredGateway))) .ReturnsAsync(bundlerResult); } TwinCollection actualSavedTwin = null; if (shouldSavePreferredGateway || shouldSaveRegion) { LoRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true) .Callback((TwinCollection t, CancellationToken _) => actualSavedTwin = t); } LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .ReturnsAsync(true); LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsAny <TimeSpan>())) .ReturnsAsync((Message)null); using var cache = EmptyMemoryCache(); using var loraDeviceCache = CreateDeviceCache(loraDevice); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, loraDeviceCache); // Send to message processor using var messageProcessor = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var payload = simulatedDevice.CreateUnconfirmedDataUpMessage("1234", fcnt: PayloadFcnt); using var request = CreateWaitableRequest(payload, constantElapsedTime: TimeSpan.Zero); messageProcessor.DispatchRequest(request); Assert.True(await request.WaitCompleteAsync()); // Expectations // 1. Message was sent to IoT Hub LoRaDeviceClient.VerifyAll(); LoRaDeviceApi.VerifyAll(); // 2. No downstream message for the current device is sent Assert.Null(request.ResponseDownlink); Assert.True(request.ProcessingSucceeded); if (!string.IsNullOrEmpty(deviceGatewayID)) { Assert.Equal(initialPreferredGatewayID, loraDevice.PreferredGatewayID); } else { Assert.Equal(preferredGatewayID, loraDevice.PreferredGatewayID); } Assert.Equal(LoRaRegionType.EU868, loraDevice.LoRaRegion); if (shouldSavePreferredGateway || shouldSaveRegion) { if (shouldSavePreferredGateway) { Assert.Equal(ServerGatewayID, actualSavedTwin[TwinProperty.PreferredGatewayID].Value as string); } else { Assert.False(actualSavedTwin.Contains(TwinProperty.PreferredGatewayID)); } if (shouldSaveRegion) { Assert.Equal(LoRaRegionType.EU868.ToString(), actualSavedTwin[TwinProperty.Region].Value as string); } else { Assert.False(actualSavedTwin.Contains(TwinProperty.Region)); } } }
public ResizablePoolCell(ActorSystemImpl system, IInternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, IInternalActorRef supervisor, Pool pool) : base(system, self, routerProps, dispatcher, routeeProps, supervisor) { if (pool.Resizer == null) { throw new ArgumentException("RouterConfig must be a Pool with defined resizer"); } resizer = pool.Resizer; _routerProps = routerProps; _pool = pool; _resizeCounter = new AtomicCounterLong(0); _resizeInProgress = new AtomicBoolean(); }
public async Task When_ABP_Sends_Upstream_Followed_By_DirectMethod_Should_Send_Upstream_And_Downstream(string deviceGatewayID, uint fcntDownFromTwin, uint fcntDelta, Region region) { const uint payloadFcnt = 2; // to avoid relax mode reset var simDevice = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(1, gatewayID: deviceGatewayID, deviceClassType: 'c'), frmCntDown: fcntDownFromTwin); LoRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); var twin = simDevice.CreateABPTwin(reportedProperties: new Dictionary <string, object> { { TwinProperty.Region, region.LoRaRegion.ToString() } }); LoRaDeviceClient.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(twin); LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull <LoRaDeviceTelemetry>(), null)) .ReturnsAsync(true); LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsNotNull <TimeSpan>())) .ReturnsAsync((Message)null); LoRaDeviceApi.Setup(x => x.SearchByDevAddrAsync(simDevice.DevAddr.Value)) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(simDevice.DevAddr, simDevice.DevEUI, "123").AsList())); if (deviceGatewayID == null) { LoRaDeviceApi.Setup(x => x.ExecuteFunctionBundlerAsync(simDevice.DevEUI, It.IsNotNull <FunctionBundlerRequest>())) .ReturnsAsync(new FunctionBundlerResult()); } using var cache = NewMemoryCache(); using var deviceRegistry = new LoRaDeviceRegistry(ServerConfiguration, cache, LoRaDeviceApi.Object, LoRaDeviceFactory, DeviceCache); using var messageDispatcher = new MessageDispatcher( ServerConfiguration, deviceRegistry, FrameCounterUpdateStrategyProvider); var payloadData = simDevice.CreateUnconfirmedDataUpMessage("1", fcnt: payloadFcnt); using var request = CreateWaitableRequest(payloadData, region: region); request.SetStationEui(new StationEui(ulong.MaxValue)); messageDispatcher.DispatchRequest(request); Assert.True(await request.WaitCompleteAsync()); Assert.True(request.ProcessingSucceeded); // wait until cache has been updated await Task.Delay(50); // Adds fcntdown to device, simulating multiple downstream calls Assert.True(DeviceCache.TryGetForPayload(request.Payload, out var loRaDevice)); loRaDevice.SetFcntDown(fcntDelta + loRaDevice.FCntDown); var classCSender = new DefaultClassCDevicesMessageSender( ServerConfiguration, deviceRegistry, DownstreamMessageSender, FrameCounterUpdateStrategyProvider, new TestOutputLogger <DefaultClassCDevicesMessageSender>(this.testOutputHelper), TestMeter.Instance); var c2d = new ReceivedLoRaCloudToDeviceMessage() { DevEUI = simDevice.DevEUI, MessageId = Guid.NewGuid().ToString(), Payload = "aaaa", Fport = FramePorts.App18, }; var expectedFcntDown = fcntDownFromTwin + Constants.MaxFcntUnsavedDelta + fcntDelta; if (string.IsNullOrEmpty(deviceGatewayID)) { LoRaDeviceApi.Setup(x => x.NextFCntDownAsync(simDevice.DevEUI, fcntDownFromTwin + fcntDelta, 0, ServerConfiguration.GatewayID)) .ReturnsAsync((ushort)expectedFcntDown); } Assert.True(await classCSender.SendAsync(c2d)); Assert.Single(DownstreamMessageSender.DownlinkMessages); var downstreamMsg = DownstreamMessageSender.DownlinkMessages[0]; var downstreamPayloadBytes = downstreamMsg.Data; var downstreamPayload = new LoRaPayloadData(downstreamPayloadBytes); Assert.Equal(expectedFcntDown, downstreamPayload.Fcnt); Assert.Equal(c2d.Fport, downstreamPayload.Fport); Assert.Equal(downstreamPayload.DevAddr, simDevice.DevAddr); var decryptedPayload = downstreamPayload.GetDecryptedPayload(simDevice.AppSKey.Value); Assert.Equal(c2d.Payload, Encoding.UTF8.GetString(decryptedPayload)); Assert.Equal(expectedFcntDown, loRaDevice.FCntDown); Assert.Equal(payloadFcnt, loRaDevice.FCntUp); LoRaDeviceApi.VerifyAll(); LoRaDeviceClient.VerifyAll(); }
public ReservedIdTests() { _store = Substitute.For<IStoreReservedMessagesIds>(); _sut =new MessageDispatcher(i=>Task.WhenAll(),_store); }
private void OnDebugServiceClientConnect(object sender, ChannelBase serverChannel) { MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger); ProtocolEndpoint protocolEndpoint = new ProtocolEndpoint( serverChannel, messageDispatcher, this.logger); protocolEndpoint.UnhandledException += ProtocolEndpoint_UnhandledException; bool ownsEditorSession = this.editorSession == null; if (ownsEditorSession) { this.editorSession = this.CreateDebugSession( this.hostDetails, profilePaths, protocolEndpoint, messageDispatcher, this.languageServer?.EditorOperations, this.enableConsoleRepl); } this.debugAdapter = new DebugAdapter( this.editorSession, ownsEditorSession, messageDispatcher, protocolEndpoint, this.logger); this.debugAdapter.SessionEnded += (obj, args) => { if (!ownsEditorSession) { this.logger.Write( LogLevel.Normal, "Previous debug session ended, restarting debug service listener..."); this.debugServiceListener.Stop(); this.debugServiceListener.Start(); } else if (this.debugAdapter.IsUsingTempIntegratedConsole) { this.logger.Write( LogLevel.Normal, "Previous temp debug session ended"); } else { // Exit the host process this.serverCompletedTask.SetResult(true); } }; this.debugAdapter.Start(); protocolEndpoint.Start(); }
public async Task When_Multiple_Joins_Are_Received_Should_Get_Twins_Once(string deviceGatewayID) { var simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateOTAADevice(1, gatewayID: deviceGatewayID)); var devAddr = string.Empty; var devEUI = simulatedDevice.LoRaDevice.DeviceID; var appEUI = simulatedDevice.LoRaDevice.AppEUI; // Device twin will be queried var twin = new Twin(); twin.Properties.Desired[TwinProperty.DevEUI] = devEUI; twin.Properties.Desired[TwinProperty.AppEUI] = simulatedDevice.LoRaDevice.AppEUI; twin.Properties.Desired[TwinProperty.AppKey] = simulatedDevice.LoRaDevice.AppKey; twin.Properties.Desired[TwinProperty.GatewayID] = deviceGatewayID; twin.Properties.Desired[TwinProperty.SensorDecoder] = simulatedDevice.LoRaDevice.SensorDecoder; this.LoRaDeviceClient.Setup(x => x.GetTwinAsync()) .ReturnsAsync(twin); // Device twin will be updated this.LoRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsNotNull <TwinCollection>())) .ReturnsAsync(true); // Lora device api will be search by devices with matching deveui this.LoRaDeviceApi.Setup(x => x.SearchAndLockForJoinAsync(this.ServerConfiguration.GatewayID, devEUI, appEUI, It.IsAny <string>())) .ReturnsAsync(new SearchDevicesResult(new IoTHubDeviceInfo(devAddr, devEUI, "aabb").AsList())); // using factory to create mock of var memoryCache = new MemoryCache(new MemoryCacheOptions()); var deviceRegistry = new LoRaDeviceRegistry(this.ServerConfiguration, memoryCache, this.LoRaDeviceApi.Object, this.LoRaDeviceFactory); var messageProcessor = new MessageDispatcher( this.ServerConfiguration, deviceRegistry, this.FrameCounterUpdateStrategyProvider); // 1st join request var joinRequest1 = this.CreateWaitableRequest(simulatedDevice.CreateJoinRequest().SerializeUplink(simulatedDevice.AppKey).Rxpk[0]); messageProcessor.DispatchRequest(joinRequest1); await Task.Delay(100); // 2nd join request var joinRequest2 = this.CreateWaitableRequest(simulatedDevice.CreateJoinRequest().SerializeUplink(simulatedDevice.AppKey).Rxpk[0]); messageProcessor.DispatchRequest(joinRequest2); await Task.WhenAll(joinRequest1.WaitCompleteAsync(), joinRequest2.WaitCompleteAsync()); Assert.Equal(2, this.PacketForwarder.DownlinkMessages.Count); Assert.NotNull(joinRequest1.ResponseDownlink); Assert.NotNull(joinRequest2.ResponseDownlink); // get twin only once called this.LoRaDeviceClient.Verify(x => x.GetTwinAsync(), Times.Once()); // get device for join called x2 this.LoRaDeviceApi.Verify(x => x.SearchAndLockForJoinAsync(ServerGatewayID, devEUI, appEUI, It.IsAny <string>()), Times.Exactly(2)); this.LoRaDeviceClient.VerifyAll(); this.LoRaDeviceApi.VerifyAll(); }
/// <summary> /// Initializes a new instance of the <see cref="JobbrServer"/> class. /// </summary> public JobbrServer(IJobScheduler scheduler, IJobExecutor jobExecutor, IJobStorageProvider jobStorageProvider, List <IJobbrComponent> components, MessageDispatcher messageDispatcher, ConfigurationManager configurationManager, RegistryBuilder registryBuilder) { Logger.Debug("A new instance of a a JobbrServer has been created."); this.scheduler = scheduler; this.executor = jobExecutor; this.components = components; this.configurationManager = configurationManager; this.registryBuilder = registryBuilder; this.jobStorageProvider = jobStorageProvider; messageDispatcher.WireUp(); }
public override void Init() { _msgQueue = new List <LockStepServerMsgItem>(); MessageDispatcher.GetInstance().AddMessageListener(MsgID.LoginReq, OnLoginReq); MessageDispatcher.GetInstance().AddMessageListener(MsgID.SteerPositionReq, OnSteerPositionReq); }
public override void Release() { MessageDispatcher.GetInstance().RemoveMessageListener(MsgID.LoginReq, OnLoginReq); MessageDispatcher.GetInstance().RemoveMessageListener(MsgID.SteerPositionReq, OnSteerPositionReq); }
public PersonAggregate(MessageDispatcher messageDispatcher) { this.messageDispatcher = messageDispatcher; }