Пример #1
0
        private async Task SeedAsync(TestContext1 context)
        {
            var triggers   = new[] { "noun.verb", "noun.verb2" };
            var pauses     = new[] { true, false };
            var principals = new[] { "principal1", "principal2" };
            var parameters = new[]
            {
                null,                              //Valid
                new Dictionary <string, object>(), //valid
                new Dictionary <string, object>    //valid
                {
                    ["property"]      = 2,
                    ["otherProperty"] = "value"
                },
                new Dictionary <string, object> //not valid
                {
                    ["property"]       = 2,
                    ["otherProperty"]  = "value",
                    ["absentProperty"] = "absent"
                },
                new Dictionary <string, object> //not valid
                {
                    ["property"]      = 20,
                    ["otherProperty"] = "value"
                },
                new Dictionary <string, object> //not valid
                {
                    ["property"]      = 20,
                    ["otherProperty"] = "wrongValue"
                },
                new Dictionary <string, object>//valid
                {
                    ["property"]      = 2,
                    ["otherProperty"] = "value",
                    ["thirdProperty"] = "nope"
                }
            };

            foreach (var principal in principals)
            {
                foreach (var trigger in triggers)
                {
                    foreach (var pause in pauses)
                    {
                        foreach (var parameter in parameters)
                        {
                            AddWebHook(context, Guid.NewGuid(), principal, trigger, pause, parameter);
                        }
                    }
                }
            }
            await context.SaveChangesAsync();
        }
Пример #2
0
        private Registrations.EFStorage.WebHookNotification AddNotification(TestContext1 context, Guid id, string trigger)
        {
            var result = new Registrations.EFStorage.WebHookNotification
            {
                Id        = id,
                TriggerId = trigger,
                Payload   = new List <int> {
                    1, 2
                }
            };

            context.Add(result);
            return(result);
        }
Пример #3
0
        private async Task SeedAsync(TestContext1 context)
        {
            var triggers   = new[] { "noun.verb", "noun.verb2" };
            var pauses     = new[] { true, false };
            var principals = new[] { "principal1", "principal2" };

            foreach (var principal in principals)
            {
                foreach (var trigger in triggers)
                {
                    foreach (var pause in pauses)
                    {
                        AddWebHook(context, Guid.NewGuid(), principal, trigger, pause);
                    }
                }
            }
            await context.SaveChangesAsync();
        }
Пример #4
0
        public void Transforming_Template2WithImport_ResultsInExpectedOutput()
        {
            // Arrange.
            var context = new TestContext1
            {
                Property1 = DateTime.Now.ToString()
            };

            var transformer = new TextTemplateTransformer(context);
            var expected    = new Template2()
            {
                Context = context
            }.TransformText();

            // Act.
            string output = transformer.TransformFile(@"Templates\Template2.tt");

            // Assert.
            Assert.AreEqual(expected, output);
        }
Пример #5
0
        private WebHook AddWebHook(TestContext1 context, Guid id, string principal, string trigger, bool isPaused)
        {
            var result = new WebHook
            {
                Id              = id,
                PrincipalId     = principal,
                IsPaused        = isPaused,
                Callback        = "http://www.example.org",
                ProtectedSecret = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTAtXw",
                Filters         = new List <WebHookFilter>
                {
                    new WebHookFilter
                    {
                        Id      = Guid.NewGuid(),
                        Trigger = trigger
                    }
                }
            };

            context.Add(result);
            return(result);
        }
        private WebHook AddWebHook(TestContext1 context, Guid id, string principal, string trigger, bool isPaused, Dictionary <string, object> param)
        {
            var result = new WebHook
            {
                Id                = id,
                PrincipalId       = principal,
                IsPaused          = isPaused,
                ProtectedCallback = "aHR0cDovL3d3dy5leGFtcGxlLm9yZw",
                ProtectedSecret   = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTAtXw",
                Filters           = new List <WebHookFilter>
                {
                    new WebHookFilter
                    {
                        TriggerId  = trigger,
                        Parameters = param
                    }
                }
            };

            context.Add(result);
            return(result);
        }