public void TestDeleteCommandWhen0RegisteredItems0Selected() { var connection = new TestConnection(); var otao = new TestOneTimeAccessOperator(); var ota = new Jupiter.Models.OneTimeAccessModel(connection, otao); ota.DeleteOneTimeAccessItemsCommand.Execute(null); Assert.AreEqual(ota.OneTimeAccessItems.Count, 0); }
public void TestAddCommand() { var connection = new TestConnection(); var otao = new TestOneTimeAccessOperator(); var ota = new Jupiter.Models.OneTimeAccessModel(connection, otao); Add(ota, "Var1", 12345, BuiltInType.Integer); Assert.AreEqual(ota.OneTimeAccessItems.Count, 1); }
private void Add(Jupiter.Models.OneTimeAccessModel ota, string name, object value, BuiltInType type) { var vi = new VariableInfo(new NodeId(name), name); vi.NewDataValue(new DataValue(new Variant(value))); ota.AddToReadWrite(new List <VariableInfo>() { vi }); }
public void TestConnect() { var connection = new TestConnection(); var otao = new TestOneTimeAccessOperator(); var varinfomgr = new VariableInfo(); var ota = new Jupiter.Models.OneTimeAccessModel(connection, otao, varinfomgr); Add(ota, "Var1", 12345, BuiltInType.Integer); connection.Connected = true; Assert.AreEqual(ota.OneTimeAccessItems.Count, 1); connection.Connected = false; Assert.AreEqual(ota.OneTimeAccessItems.Count, 0); }
private void Add(Jupiter.Models.OneTimeAccessModel ota, string name, object value, BuiltInType type) { ota.AddToReadWrite(new List <IVariableConfiguration>() { new TestVariableConfiguration() { NodeClass = NodeClass.Variable, TestBuiltInType = type, TestVariableNodeId = new NodeId(name), Value = value, } }); }
public void TestDeleteCommandWhen1RegisteredItems0Selected() { var connection = new TestConnection(); var otao = new TestOneTimeAccessOperator(); var ota = new Jupiter.Models.OneTimeAccessModel(connection, otao); Add(ota, "Var1", 12345, BuiltInType.Integer); ((VariableInfo)ota.OneTimeAccessItems[0]).PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { ota.OneTimeAccessSelectedItems = new ObservableCollection <VariableInfo>(); ota.OneTimeAccessSelectedItems.Add(sender); }; ota.DeleteOneTimeAccessItemsCommand.Execute(null); Assert.AreEqual(ota.OneTimeAccessItems.Count, 0); }
public void TestStateOfWriteCommand() { var connection = new TestConnection(); var otao = new TestOneTimeAccessOperator(); var ota = new Jupiter.Models.OneTimeAccessModel(connection, otao); bool flag; flag = ota.WriteCommand.CanExecute(null); Assert.AreEqual(flag, false); connection.Connected = true; flag = ota.WriteCommand.CanExecute(null); Assert.AreEqual(flag, false); Add(ota, "Var1", 12345, BuiltInType.Integer); flag = ota.ReadCommand.CanExecute(null); Assert.AreEqual(flag, true); }
public void TestDeleteCommandWhen2RegisteredItems1Selected() { var connection = new TestConnection(); var otao = new TestOneTimeAccessOperator(); var varinfomgr = new VariableInfo(); var ota = new Jupiter.Models.OneTimeAccessModel(connection, otao, varinfomgr); Add(ota, "Var1", 12345, BuiltInType.Integer); Add(ota, "Var2", 23456, BuiltInType.Integer); ota.OneTimeAccessSelectedItems = new ObservableCollection <VariableInfoBase>(); foreach (VariableInfoBase vib in ota.OneTimeAccessItems) { vib.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { ota.OneTimeAccessSelectedItems.Add(sender); }; } ((VariableInfoBase)ota.OneTimeAccessItems[0]).IsSelected = true; ota.DeleteOneTimeAccessItemsCommand.Execute(null); Assert.AreEqual(ota.OneTimeAccessItems.Count, 1); Assert.AreEqual(((VariableInfoBase)ota.OneTimeAccessItems[0]).NodeId, "Var2"); }
private void ReadCommandBase(string endpoint, List <TestPattern> testPatterns) { var variables = _readCommandBase_CreateTestVariables(testPatterns); var application = _readCommandBase_CreateApplication(endpoint); using (var s = TestServer.TestServer.StartServer(application, variables)) { _readCommandBase_ServerInit(s, testPatterns); var ea = new Prism.Events.EventAggregator(); var msg = ""; ea.GetEvent <Jupiter.Events.ErrorNotificationEvent>() .Subscribe(x => msg = x.Message); var c = new Client(ea); var references = new OPCUAReference(c, null, ea); var ota = new Jupiter.Models.OneTimeAccessModel(c, c); ota.EventAggregator = ea; var nodegrid = new Jupiter.Models.NodeInfoDataGridModel(c, c); var nodetree = new Jupiter.Models.NodeTreeModel(c, references, null, ota); nodetree.EventAggregator = ea; c.EventAggregator .GetEvent <Jupiter.Events.NowLoadingEvent>() .Subscribe((x) => { var first = x.ServerList.First(); x.Client.BrowseSecurityList(first); for (int i = 0; i < first.Endpoints.Count; i++) { if (first.Endpoints[i].SecurityMode.ToString().EndsWith("None")) { Console.WriteLine(first.Endpoints[i].SecurityMode); x.SelectedIndex = i; x.SelectedServerIndex = 0; x.Result = true; break; } } }); c.CreateSession(endpoint).Wait(); foreach (OPCUAReference ch in references.Children) { if (ch.DisplayName != "TestData") { continue; } nodetree.UpdateVariableNodeListCommand.Execute(ch); foreach (VariableInfo vn in nodetree.VariableNodes) { nodetree.AddToReadWriteCommand.Execute(new List <VariableInfo>() { vn }); } } ; ota.ReadCommand.Execute(null); Assert.AreEqual(msg, ""); Assert.AreEqual(ota.OneTimeAccessItems.Count, testPatterns.Count); for (int i = 0; i < testPatterns.Count; i++) { var got = ((VariableInfo)ota.OneTimeAccessItems[i]).Value.ToString(); var want = testPatterns[i].Value.ToString(); Assert.AreEqual(got, want); } } }