public void TestInsufficientPermissions() {
            var pushEvents = new PushEventsController();

            var result = pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id", "http://localhost/", "key", 1, new List<String>() {
                "EventName"
            })
            .SetOrigin(CommandOrigin.Remote)
            .SetAuthentication(new CommandAuthenticationModel() {
                Username = "******"
            }));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType);
        }
        public void TestSuccess() {
            var pushEvents = new PushEventsController();
            
            pushEvents.Shared.Security.Tunnel(CommandBuilder.SecurityAddGroup("GroupName").SetOrigin(CommandOrigin.Local));
            pushEvents.Shared.Security.Tunnel(CommandBuilder.SecurityGroupAddAccount("GroupName", "Phogue").SetOrigin(CommandOrigin.Local));
            pushEvents.Shared.Security.Tunnel(CommandBuilder.SecurityGroupSetPermission("GroupName", CommandType.EventsEstablishJsonStream, 5).SetOrigin(CommandOrigin.Local));

            var result = pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id", "http://localhost/", "key", 1, new List<String>() {
                "EventName"
            }).SetOrigin(CommandOrigin.Remote).SetAuthentication(new CommandAuthenticationModel() {
                Username = "******"
            }));

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
        public void TestSuccessEndPointAdded() {
            var pushEvents = new PushEventsController();

            pushEvents.Execute();

            pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id", "http://localhost/", "key", 10, new List<String>() {
                "EventName"
            }).SetOrigin(CommandOrigin.Local));

            Assert.AreEqual("id", pushEvents.EndPoints.First().Value.Id);
            Assert.AreEqual(new Uri("http://localhost/"), pushEvents.EndPoints.First().Value.Uri);
            Assert.AreEqual("key", pushEvents.EndPoints.First().Value.StreamKey);
            Assert.AreEqual(10, pushEvents.EndPoints.First().Value.Interval);
            Assert.AreEqual(new List<String>() {
                "EventName"
            }, pushEvents.EndPoints.First().Value.InclusiveNames);
        }
        public void TestSuccessPreviouslySetupWillReflash() {
            var pushEvents = new PushEventsController();

            // Set an existing value for the EventsPushConfigGroups
            pushEvents.Shared.Variables.Tunnel(CommandBuilder.VariablesSet(CommonVariableNames.EventsPushConfigGroups, "id1").SetOrigin(CommandOrigin.Local));

            pushEvents.Execute();

            // Setup a end point to use previously set EventsPushConfigGroups id
            pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id1", "http://localhost/", "key1", 10, new List<String>() {
                "EventName1"
            }).SetOrigin(CommandOrigin.Local));

            // This id should be set in the config.
            Assert.AreEqual(1, pushEvents.Shared.Variables.FlashVariables.First(archive => archive.Key.ToLower() == CommonVariableNames.EventsPushConfigGroups.ToString().ToLower()).Value.ToList<String>().Count);
        }
        public void TestSuccessTwoEndPointsSaved() {
            var pushEvents = new PushEventsController();

            pushEvents.Execute();

            pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id1", "http://localhost/", "key1", 10, new List<String>() {
                "EventName1"
            }).SetOrigin(CommandOrigin.Local));

            pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id2", "http://lolcatshost/", "key2", 20, new List<String>() {
                "EventName2"
            }).SetOrigin(CommandOrigin.Local));

            Assert.AreEqual(2, pushEvents.Shared.Variables.FlashVariables.First(archive => archive.Key.ToLower() == CommonVariableNames.EventsPushConfigGroups.ToString().ToLower()).Value.ToList<String>().Count);
        }
        public void TestSuccessTwoEndPointsEstablished() {
            var pushEvents = new PushEventsController();

            pushEvents.Execute();

            pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id1", "http://localhost/", "key1", 10, new List<String>() {
                "EventName1"
            }).SetOrigin(CommandOrigin.Local));

            pushEvents.Tunnel(CommandBuilder.EventsEstablishJsonStream("id2", "http://lolcatshost/", "key2", 20, new List<String>() {
                "EventName2"
            }).SetOrigin(CommandOrigin.Local));

            Assert.AreEqual(2, pushEvents.EndPoints.Count);
        }