public async Task CanForwardToMultipleRecipients()
        {
            var network = new InMemNetwork();
            var activator = new BuiltinHandlerActivator();

            Using(activator);

            var recipients = new[] { "recipient-A", "recipient-B" }.ToList();

            recipients.ForEach(network.CreateQueue);

            Configure.With(activator)
                .Transport(t => t.UseInMemoryTransport(network, "forwarder"))
                .Routing(t =>
                {
                    t.AddTransportMessageForwarder(async transportMessage => ForwardAction.ForwardTo(recipients));
                })
                .Start();

            await activator.Bus.SendLocal("HEJ MED DIG!!!");

            var transportMessages = await Task.WhenAll(recipients.Select(async queue =>
            {
                var message = await network.WaitForNextMessageFrom(queue);

                return message;
            }));

            Assert.That(transportMessages.Length, Is.EqualTo(2));
        }
Example #2
0
 public void SaveOrLoad(Serializer ser)
 {
     var snmTriggerEntries = new []
     {
         LoadAndSaveEntry.Create(r => Sound = r.ReadInt16(), w => w.WriteInt16(Sound), 54),
         LoadAndSaveEntry.Create(r => Id = r.ReadByte(), w => w.WriteByte(Id), 54),
         LoadAndSaveEntry.Create(r => Expire = r.ReadUInt16(), w => w.WriteUInt16(Expire), 54),
             LoadAndSaveEntry.Create(r => Command = r.ReadUInt16s(8).Select(i => (int)i).ToArray(), w => w.WriteUInt16s(Command.Select(i => (ushort)i).ToArray(), 8), 54),
     };
     snmTriggerEntries.ForEach(e => e.Execute(ser));
 }
        public void Initialize(IScriptPackSession session)
        {
            var namespaces = new[]
            {
               "Microsoft.Xrm.Sdk.Client",
               "Microsoft.Xrm.Sdk",
               "Microsoft.Xrm.Sdk.Query",
               "Microsoft.Xrm.Sdk.Messages",
               "Microsoft.Crm.Sdk.Messages"
            }.ToList();
             namespaces.ForEach(session.ImportNamespace);

             session.AddReference("System.Runtime.Serialization");
        }
        public void Should_Deny_Urls()
        {
            var service = new DefaultUrlService(null, null);

            var invalidUrls = new[]
                {
                    @"//",
                    @"a//a",
                    @"b//a/",
                    @"c/a/a/a/a/a/a/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/a",
                    @"dsdasd\asdasdasdas",
                    @"esdas$asdasdasdasd",
                }.ToList();

            invalidUrls.ForEach(url => Assert.IsFalse(service.ValidateUrl(url), string.Format("URL must be invalid: '{0}'", url)));
        }
        public void Should_Allow_Urls()
        {
            var service = new DefaultUrlService(null, null);

            var validUrls = new[]
                {
                    @"/",
                    @"/a/",
                    @"bsd-asd",
                    @"c/a",
                    @"d/a/a/a/a/a/a/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/a",
                    @"e/a/a/a/a/a/a/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaa/a",
                    @"/fasd/aasd/aasd/aasdasdad/aasdasd/asdasda/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/a",
                    @"gsad/aa",
                    @"/hasd",
                    @"/j",
                    @"/ksdasdasd/",
                    @"/شسیللانتلان/",
                    @"/уцкевапрнгш-енгшен/",
                }.ToList();

            validUrls.ForEach(url => Assert.IsTrue(service.ValidateUrl(url), string.Format("URL must be valid: '{0}'", url)));
        }
        public void WhenGettingSpeakerSessionsOnlySessionsForThatSpeakerAreReturned()
        {
            var speaker1FirstName = "Test";
            var speaker1LastName = "Speaker";
            var speaker1SessionNames = "Sessions by Speaker 1";

            var speaker2FirstName = "Other";
            var speaker2LastName = "Presenter";
            var speaker2SessionNames = "Sessions by Speaker 2";

            // Assemble
            var dbContext = new InMemoryOCCDB()
                .WithEvent("Test Code Camp")
                .WithPerson(speaker1FirstName, speaker1LastName)
                .WithPerson(speaker2FirstName, speaker2LastName);

            var @event = dbContext.Events.First();
            var speaker1 = dbContext.People.First(p => p.FirstName.Equals(speaker1FirstName) && p.LastName.Equals(speaker1LastName));
            var speaker2 = dbContext.People.First(p => p.FirstName.Equals(speaker2FirstName) && p.LastName.Equals(speaker2LastName));

            var sessions = new[]
            {
                new Data.Session
                {
                    Event_ID = @event.ID,
                    Name = speaker1SessionNames,
                    Speaker_ID = speaker1.ID,
                },
                new Data.Session
                {
                    Event_ID = @event.ID,
                    Name = speaker1SessionNames,
                    Speaker_ID = speaker1.ID,
                },
                new Data.Session
                {
                    Event_ID = @event.ID,
                    Name = speaker1SessionNames,
                    Speaker_ID = speaker1.ID,
                },
                new Data.Session
                {
                    Event_ID = @event.ID,
                    Name = speaker2SessionNames,
                    Speaker_ID = speaker2.ID,
                },
                new Data.Session
                {
                    Event_ID = @event.ID,
                    Name = speaker2SessionNames,
                    Speaker_ID = speaker2.ID,
                }
            };

            sessions.ForEach(s=>dbContext.Sessions.Add(s));
            dbContext.SaveChanges();

            var service = TestHelper.GetTestService(dbContext);

            // Act
            var speaker2Sessions = service.GetSpeakerSessions(@event.ID,speaker2.ID);

            // Assert
            Assert.AreEqual(speaker2Sessions.Count(), 2);

            speaker2Sessions.ForEach(s =>
            {
                Assert.AreEqual(s.Name,speaker2SessionNames);
            });
        }