public void IsInvalidNoReferences() { RemoteApp app = new RemoteApp(); Assert.IsFalse(app.IsValid); Assert.AreEqual("No remote controls are connected to Sammie. Please make sure that your remote is plugged into Sammie.", app.InvalidMessage); }
/// <summary> /// Call when you are ready to pull down the data associated with this object /// </summary> public void Update(bool force = false) { if (!force && (Opened || (RemoteFile != null && !RemoteFile.IsDirectory()))) { return; } // if we are forcing an update then the assumption is that we want an update // of either the current item or its container. If this is not a directory and // we have been forced, force an update on the parent if (force && !IsApplication && (RemoteFile != null && !RemoteFile.IsDirectory())) { if (this.Parent != null) { this.Parent.Update(force: true); } return; } Children.Clear(); //Opened = true; Opened = true; IRemoteIsolatedStorageFile remoteIso = _remoteStore; if (remoteIso == null) { if (RemoteApp.InstanceID == Guid.Empty) { // 8.1 UpdateModern(force); return; } else { remoteIso = RemoteApp.GetIsolatedStore("Local"); } } List <IRemoteFileInfo> remoteFiles; try { if (remoteIso != null) { remoteFiles = remoteIso.GetDirectoryListing(_path); foreach (IRemoteFileInfo remoteFile in remoteFiles) { Children.Add(new RemoteAppIsoStoreItem(_appEx, remoteFile, remoteIso, this)); } } } catch (FileNotFoundException) { // no files, oh well :) } }
public void IsValid() { RemoteApp app = new RemoteApp(); IOInterfaceReference ref1 = new IOInterfaceReference(); app.AddChild(ref1); Assert.IsTrue(app.IsValid); Assert.AreEqual(String.Empty, app.InvalidMessage); }
public void AddPowerRemoteReference() { RemoteApp app = new RemoteApp(); PowerRemoteReference ref1 = new PowerRemoteReference(); ref1.Properties.Single(r => r.Name.Equals("RemoteName")).Setter("Test Remote"); app.AddChild(ref1); Assert.AreEqual(1, app.Children.Count()); Assert.IsInstanceOfType(app.Children.First(), typeof(IOInterfaceReference)); Assert.AreEqual("Power", (app.Children.First() as IOInterfaceReference).Tag); Assert.AreEqual("Test Remote", (app.Children.First() as IOInterfaceReference).Name); }
public void ReferencesAppearInProperty() { RemoteApp app = new RemoteApp(); IOInterfaceReference ref1 = new IOInterfaceReference(); app.AddChild(ref1); IOInterfaceReference ref2 = new IOInterfaceReference(); app.AddChild(ref2); Mock <IParseable> notARef = new Mock <IParseable>(MockBehavior.Strict); notARef.Setup(s => s.IsValid).Returns(true); IEnumerable <IOInterfaceReference> references = app.References; Assert.AreEqual(2, references.Count()); Assert.IsTrue(references.Contains(ref1)); Assert.IsTrue(references.Contains(ref2)); }
private void TestGrammar(String channel, String remoteButton, String dialog) { Dictionary <String, String> expectedParams = new Dictionary <string, string> { { "Command", "remote" }, { "remoteButton", remoteButton }, { "channel", channel }, }; Mock <ITVRemote> remote = new Mock <ITVRemote>(MockBehavior.Strict); remote.Setup(s => s.IsValid).Returns(true); remote.Setup(s => s.GetChannels()).Returns(new List <String> { "Test Channel" }); AddComponentToConfigurationManager(remote.Object); RemoteApp app = new RemoteApp(); app.AddChild(new IOInterfaceReference()); TestGrammar(app, GetConfigurationManager(), dialog, expectedParams); remote.Verify(s => s.GetChannels(), Times.Exactly(1)); }
protected RemoteApplicationModule(string path, SContext serverContext) : base(AccessScope.globalScope, User.Role.User, path, serverContext) { this.Before += async(ctx) => { // verify the app secret var appSecret = ctx.Request.Headers[Constants.APP_SECRET_HEADER]; if (string.IsNullOrEmpty(appSecret)) { ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized; return(false); } // match the token to an app remoteApp = serverContext.config.apps.SingleOrDefault(x => x.name == credential.scope.app); if (remoteApp == null || remoteApp.secret != appSecret) { ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized; return(false); } return(true); }; }
protected override void load(TomlTable tb) { var serverTable = tb.getTable(nameof(server)); serverTable.autoBind(server); var appsTables = tb.getTableArray(nameof(apps)); foreach (var appTable in appsTables) { var cfgApp = new RemoteApp(); appTable.autoBind(cfgApp); // validate app if (!StringValidator.isIdentifier(cfgApp.name)) { throw new ConfigurationException(nameof(cfgApp.name), $"app name '{cfgApp.name}' is not valid"); } if (string.IsNullOrEmpty(cfgApp.secret)) { throw new ConfigurationException(nameof(cfgApp.secret), "app secret cannot be empty"); } apps.Add(cfgApp); } var groupsTables = tb.getTableArray(nameof(groups)); foreach (var groupTable in groupsTables) { var cfgGroup = new Group { name = groupTable.getField <string>(nameof(Group.name)), priority = groupTable.getField <long>(nameof(Group.priority)) }; // validate group if (!StringValidator.isIdentifier(cfgGroup.name)) { throw new ConfigurationException(nameof(cfgGroup.name), $"group name '{cfgGroup.name}' is not a valid identifier."); } // load permissions and rules cfgGroup.permissions = groupTable.getField <TomlArray>(nameof(Group.permissions)) .Select(x => new Permission(x.ToString())) .ToList(); var groupRules = groupTable.getTable(nameof(Group.rules)); foreach (var appRulesTablePair in groupRules) { var ruleApp = appRulesTablePair.Key; var rulesTable = (TomlTable)appRulesTablePair.Value; foreach (var appRule in rulesTable) { cfgGroup.rules.Add(new AccessRule(ruleApp, appRule.Key, appRule.Value.ToString())); } } groups.Add(cfgGroup); } var usersTable = tb.getTable(nameof(users)); usersTable.autoBind(users); var loggingTable = tb.getTable(nameof(logging)); loggingTable.autoBind(logging); }
public void Remove(RemoteApp remoteApp) { List.Remove(remoteApp); }
public void Add(RemoteApp remoteApp) { List.Add(remoteApp); }