public async Task GetSystemInformationsV5() { var rpcClient = new Mock <IRpcClient>(); //rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) // .ReturnsAsync("Usul"); //rpcClient.SetupSequence(c => c.ExecuteTaskAsync<object>(It.IsAny<IRpcRequest>())) // .ReturnsAsync("Usul") // .ReturnsAsync(new OMVInformations()); // rpcClient.Setup(c => c.ExecuteTaskAsync<It.IsSubtype<OMVInformations>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) // .ReturnsAsync("Usul"); rpcClient.Setup(c => c.ExecuteTaskAsync <object>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(OMVVersions.Usul); rpcClient.Setup(c => c.ExecuteTaskAsync <OMVInformations>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(new OMVInformations()); var obj = new OmvSystemClient(rpcClient.Object); Assert.IsNotNull(obj); obj.SetOMVVersion(OMVVersions.Version5); var result = await obj.GetSystemInformations(); Assert.IsNotNull(result); }
public async Task GetSystemInformationsV6() { var rpcClient = new Mock <IRpcClient>(); rpcClient.Setup(c => c.ExecuteTaskAsync <object>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(OMVVersions.Shaitan); rpcClient.Setup(c => c.ExecuteTaskAsync <Doods.Openmediavault.Rpc.Std.Data.V6.OMVInformations>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(new Doods.Openmediavault.Rpc.Std.Data.V6.OMVInformations()); var obj = new OmvSystemClient(rpcClient.Object); Assert.IsNotNull(obj); obj.SetOMVVersion(OMVVersions.Version6); var result = await obj.GetSystemInformations(); Assert.IsNotNull(result); }
public void SetOMVVersion(OMVVersion version) { _omvSystemClient.SetOMVVersion(version); }
public async Task GetSystemInformationsV4() { var rpcClient = new Mock <IRpcClient>(); var slt = new List <SystemInformation>(); var info = new SystemInformation(); info.Name = "ts"; info.Value = (ValueUnion)"1000"; slt.Add(info); info = new SystemInformation(); info.Name = "System time"; info.Value = (ValueUnion)"System_time_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Hostname"; info.Value = (ValueUnion)"Hostname_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Version"; info.Value = (ValueUnion)"Version_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Processor"; info.Value = (ValueUnion)"Processor_string"; slt.Add(info); info = new SystemInformation(); info.Name = "MemTotal"; info.Value = (ValueUnion)"2000"; slt.Add(info); info = new SystemInformation(); info.Name = "Kernel"; info.Value = (ValueUnion)"Kernel_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Uptime"; info.Value = (ValueUnion)"Uptime_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Load average"; info.Value = (ValueUnion)"Load_average_string"; slt.Add(info); info = new SystemInformation(); info.Name = "configDirty"; info.Value = (ValueUnion)"true"; slt.Add(info); info = new SystemInformation(); info.Name = "rebootRequired"; info.Value = (ValueUnion)"false"; slt.Add(info); info = new SystemInformation(); info.Name = "pkgUpdatesAvailable"; info.Value = (ValueUnion)"true"; slt.Add(info); //rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>>(It.IsAny<IRpcRequest>())) // .ReturnsAsync(slt); //rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>>(It.IsAny<IRpcRequest>())) // .ReturnsAsync(slt); rpcClient.Setup(c => c.ExecuteTaskAsync <object>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(OMVVersions.Arrakis); rpcClient.Setup(c => c.ExecuteTaskAsync <IEnumerable <SystemInformation> > (It.IsAny <IRpcRequest>())) .ReturnsAsync(slt); //rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) // .ReturnsAsync("Arrakis"); var obj = new OmvSystemClient(rpcClient.Object); Assert.IsNotNull(obj); obj.SetOMVVersion(OMVVersions.Version4); var result = await obj.GetSystemInformations(); Assert.IsNotNull(result); }