public ConnectorCollection CreateConnectorCollection() { var plug = new Plug(); var connectorCollection = new ConnectorCollection(); connectorCollection.Connectors.Add(plug); return connectorCollection; }
public void CreatedPlugCanBeDisconnected() { var stream = Substitute.For<IAudioStream>(); var plug = new Plug<IAudioStream>(stream); plug.Disconnect(); plug.IsConnected.Should().Be.False(); }
public void CanConnectSocketToPlug() { var stream = Substitute.For<IAudioStream>(); var plug = new Plug<IAudioStream>(stream); var socket = new Socket<IAudioStream>(); socket.ConnectTo(plug).Should().Be.True(); }
public void RemoveHalfPlug(Plug plug) { try { plugs.Remove(plug); Plugs_ListBox.ItemsSource = plugs; } catch (Exception) { } }
public void CanConnectPlugToSocket() { var stream = Substitute.For<IAudioStream>(); var plug = new Plug<IAudioStream>(stream); var socket = new Socket<IAudioStream>(); plug.ConnectTo(socket).Should().Be.True(); }
//--- Methods --- protected override Yield Start(XDoc config, Result result) { yield return Coroutine.Invoke(base.Start, config, new Result()); _redirect = Plug.New(config["proxy"].AsUri ?? config["redirect"].AsUri, TimeSpan.FromSeconds(config["timeout"].AsInt ?? (int)Plug.DEFAULT_TIMEOUT.TotalSeconds)); if(_redirect == null) { throw new ArgumentException("redirect URI missing or invalid"); } result.Return(); }
public void ConnectedSocketIsConnected() { var stream = Substitute.For<IAudioStream>(); var plug = new Plug<IAudioStream>(stream); var socket = new Socket<IAudioStream>(); plug.ConnectTo(socket); socket.IsConnected.Should().Be.True(); }
public void ConnectingSetsSocketChannel() { var stream = Substitute.For<IAudioStream>(); var plug = new Plug<IAudioStream>(stream); var socket = new Socket<IAudioStream>(); plug.ConnectTo(socket); Assert.Same(stream, socket.Channel); }
public void Ratings_GetRatingInfoForUnratedPage_NoData() { // Build ADMIN plug Plug p = Utils.BuildPlugForAdmin(); // Create random page string id = null; string path = null; DreamMessage msg = PageUtils.CreateRandomPage(p, out id, out path); // Retrieve rating info for unrated page and assert correct data is returned msg = p.At("pages", id, "ratings").GetAsync().Wait(); Assert.AreEqual(DreamStatus.Ok, msg.Status, "Page rating retrieval failed!"); Assert.AreEqual(String.Empty, msg.ToDocument()["@score"].AsText, "Score attribute contains a value!"); Assert.AreEqual(0, msg.ToDocument()["@count"].AsInt, "Unrated page count does not equal 0!"); }
public void GetPageAliases() { // GET:pages/{pageid}/aliases // http://developer.mindtouch.com/Deki/API_Reference/GET%3apages%2f%2f%7bpageid%7d%2f%2faliases Plug p = Utils.BuildPlugForAdmin(); string id = null; string path = null; DreamMessage msg = PageUtils.CreateRandomPage(p, out id, out path); msg = p.At("pages", id, "aliases").Get(); Assert.AreEqual(DreamStatus.Ok, msg.Status); PageUtils.DeletePageByID(p, id, true); }
private void rc_timestamp_check(DreamMessage msg, int pageid) { Plug p = Utils.BuildPlugForAdmin(); // Retrieve page date.modified and strip all non-digit characters DreamMessage newmsg = p.At("pages", pageid.ToString()).GetAsync().Wait(); Assert.AreEqual(DreamStatus.Ok, newmsg.Status, "Page retrieval failed"); string timestamp = newmsg.ToDocument()["date.modified"].AsText ?? String.Empty; timestamp = Regex.Replace(timestamp, "[^0-9]", ""); string timestampMeta = msg.ToDocument()["change/rc_timestamp"].AsText ?? String.Empty; Assert.AreEqual(timestamp, timestampMeta, "Unexpected rc_timestamp"); }
public void Can_differentiate_multiple_plugs_and_their_call_counts() { var bar = MockPlug.Setup(new XUri("http://mock/foo")).At("bar").ExpectAtLeastOneCall(); var eek = MockPlug.Setup(new XUri("http://mock/foo")).At("eek").With("a", "b").ExpectCalls(Times.Exactly(3)); var baz = MockPlug.Setup(new XUri("http://mock/foo")).At("eek").With("b", "c").ExpectAtLeastOneCall(); Assert.IsTrue(Plug.New("http://mock/foo/bar").Get(new Result <DreamMessage>()).Wait().IsSuccessful); Assert.IsTrue(Plug.New("http://mock/foo/bar").Get(new Result <DreamMessage>()).Wait().IsSuccessful); Assert.IsTrue(Plug.New("http://mock/foo/eek").With("a", "b").Get(new Result <DreamMessage>()).Wait().IsSuccessful); Assert.IsTrue(Plug.New("http://mock/foo/eek").With("a", "b").Get(new Result <DreamMessage>()).Wait().IsSuccessful); Assert.IsTrue(Plug.New("http://mock/foo/eek").With("a", "b").Get(new Result <DreamMessage>()).Wait().IsSuccessful); Assert.IsTrue(Plug.New("http://mock/foo/eek").With("b", "c").Get(new Result <DreamMessage>()).Wait().IsSuccessful); bar.Verify(); baz.Verify(); eek.Verify(); }
internal static XDoc ExecuteScript(Plug env, DreamHeaders headers, XDoc script) { // execute script commands XDoc reply = new XDoc("results"); string ID = script["@ID"].Contents; if (!string.IsNullOrEmpty(ID)) { reply.Attr("ID", ID); } foreach (XDoc cmd in script.Elements) { reply.Add(ExecuteCommand(env, headers, cmd)); } return(reply); }
public void RemovePlug(Plug plug) { if (inputs.Remove(plug)) { return; } if (outputs.Remove(plug)) { return; } if (unconnected.Remove(plug)) { return; } Utils.Unreachable(); }
public static Plug WithCheck(this Plug plug, string fieldName, object fieldValue) { if (fieldValue == null || fieldName == null || String.IsNullOrWhiteSpace(fieldName)) { return(plug); } if (fieldValue is string && !String.IsNullOrWhiteSpace(fieldValue as string)) { return(plug.With(fieldName, fieldValue as string)); } if (fieldValue is bool? && (fieldValue as bool?).HasValue) { return(plug.With(fieldName, (fieldValue as bool?).Value)); } return(plug); }
private void CreateStorageService() { // create storage service XDoc config = new XDoc("config"); config.Elem("path", "storage"); config.Elem("sid", "sid://mindtouch.com/2007/03/dream/storage"); config.Elem("folder", _storageFolder); //DreamMessage result = _host.Self.At("services").PostAsync(config).Wait(); DreamMessage result = _hostInfo.LocalHost.At("host", "services").With("apikey", _hostInfo.ApiKey).PostAsync(config).Wait(); Assert.IsTrue(result.IsSuccessful, result.ToText()); // initialize storage plug _storage = _hostInfo.LocalHost.At("storage"); }
public void GetPageProperties() { Plug p = Utils.BuildPlugForAdmin(); string id = null; string path = null; DreamMessage msg = PageUtils.CreateRandomPage(p, out id, out path); msg = p.At("pages", id, "properties").GetAsync().Wait(); Assert.AreEqual(DreamStatus.Ok, msg.Status); msg = p.At("pages", "=" + XUri.DoubleEncode(path), "properties").GetAsync().Wait(); Assert.AreEqual(DreamStatus.Ok, msg.Status); PageUtils.DeletePageByID(p, id, true); }
// Called when an object is snapped in public void OnSnap(object sender, SnapDropZoneEventArgs e) { Plug snappedPlug = e.snappedObject.GetComponent <Plug>(); if (!snappedPlug) { Debug.LogError("Snapped obj not a plug"); return; } // Try to plug it in if (!PlugIn(snappedPlug)) { Debug.LogError("Unable to snap plug in"); _snapDropZone.ForceUnsnap(); } }
private Plug AttachChildViaPlug(uint socket, Gtk.Widget child) { System.Diagnostics.Trace.WriteLine("Attaching plug to socket " + socket); Plug plug = new Plug(socket); //if our plugs are unrealised and reattached too quickly, parent may not have removed the child yet if (child.Parent != null) { ((Container)child.Parent).Remove(child); } plug.Add(child); plug.Unrealized += RemovePlugChildWhenUnrealised; plug.Show(); return(plug); }
// Fill the jack with a plug public bool PlugIn(Plug plug) { _lightControl.ChangeState(LightState.ON); Click(); if (IsFree) { _plug = plug; _plug.PlugIn(this); Debug.Log("Plugged " + _plug + " into " + gameObject.name); return(true); } else { return(false); } }
public void GlobalInit() { Utils.Settings.ShutdownHost(); _adminPlug = Utils.BuildPlugForAdmin(); _log.DebugFormat("admin plug: {0}", _adminPlug.Uri.ToString()); _userId = null; _userName = null; UserUtils.CreateRandomContributor(_adminPlug, out _userId, out _userName); _log.DebugFormat("created contributor {0} ({1})", _userName, _userId); _pageSubscriberPlug = Utils.BuildPlugForUser(_userName); _log.DebugFormat("subscriber plug: {0}", _pageSubscriberPlug.Uri.ToString()); _pageSub = _pageSubscriberPlug.At("pagesubservice"); DreamMessage response = PageUtils.CreateRandomPage(_adminPlug); Assert.IsTrue(response.IsSuccessful); }
public void GetSettingsIncludingAnonymousUserInfo() { // GET:site/settings // http://developer.mindtouch.com/Deki/API_Reference/GET%3asite%2f%2fsettings Plug p = Utils.BuildPlugForAdmin(); var siteSettingsAnon = p.At("site", "settings").With("apikey", Utils.Settings.ApiKey).With("include", "anonymous").Get().ToDocument()[ConfigBL.ANONYMOUS_USER].Contents; Assert.IsFalse(String.IsNullOrEmpty(siteSettingsAnon), "Anonymous user information wasn't included in site's settings response"); // NOTE (cesarn): We are commenting out the assertion that the JSON strings are exactly the same due // to a problem/race-condition we have in the testing environment in which internal // and public requests generate different HREF values. // var anonymous = p.At("users", "=Anonymous").Get().ToDocument().ToJson(); // Assert.AreEqual(anonymous, siteSettingsAnon, "The information for Anonymous user from the site's settings does not match with the original Anonymous user information"); }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType <Foo>().As <IFoo>().RequestScoped(); _hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.Default)); _hostInfo.Host.Self.At("load").With("name", "test.mindtouch.dream").Post(DreamMessage.Ok()); var config = new XDoc("config") .Elem("path", "test") .Elem("sid", "http://services.mindtouch.com/dream/test/2010/07/featuretestserver"); DreamMessage result = _hostInfo.LocalHost.At("host", "services").With("apikey", _hostInfo.ApiKey).PostAsync(config).Wait(); Assert.IsTrue(result.IsSuccessful, result.ToText()); _plug = Plug.New(_hostInfo.LocalHost.Uri.WithoutQuery()).At("test"); _blueprint = _plug.At("@blueprint").Get().ToDocument(); }
private int CreateDekiPage(Plug p, string pagePath, string pageTitle, DateTime?modified, string content, out string dekiPageUrl) { Log.DebugFormat("Creating page: '{0}' Content? {1}", XUri.DoubleDecode(pagePath), !string.IsNullOrEmpty(content)); Plug pagePlug = p.At("pages", "=" + pagePath, "contents"); pagePlug = pagePlug.With("abort", "never"); modified = modified ?? DateTime.Now; string editTime = Utils.FormatPageDate(modified.Value.ToUniversalTime()); pagePlug = pagePlug.With("edittime", editTime); pagePlug = pagePlug.With("comment", "Created at " + modified.Value.ToShortDateString() + " " + modified.Value.ToShortTimeString()); if (pageTitle != null) { pagePlug = pagePlug.With("title", pageTitle); } DreamMessage msg = DreamMessage.Ok(MimeType.TEXT_UTF8, content); DreamMessage res = pagePlug.PostAsync(msg).Wait(); if (res.Status != DreamStatus.Ok) { WriteLineToConsole("Error converting page \"" + XUri.DoubleDecode(pagePath) + "\""); WriteLineToLog("Edit time: " + editTime); WriteLineToLog("Page title: " + pageTitle); WriteErrorResponse(res); WriteErrorRequest(msg); } else { XDoc createdPage = res.AsDocument(); int pageId = createdPage["page/@id"].AsInt.Value; //dekiPageUrl = createdPage["page/path"].AsText; //Using the uri.ui instead of path to not worry about encodings for links //But this makes the values (mt urls) in the link mapping table unsuitable for page paths //(such as those used in dekiscript for macros). Those need to be converted to paths // via Utils.ConvertPageUriToPath dekiPageUrl = createdPage["page/uri.ui"].AsText; return(pageId); } dekiPageUrl = null; return(-1); }
private void OnClickOutPlug(Plug out_plug) { //outplug clicked when there is already an output Connection remove_connection = null; foreach (KeyValuePair <int, Connection> connection_pair in m_nodeGraphModel.GetConnections()) { Connection connection = connection_pair.Value; if (connection.m_outputPlugId == out_plug.m_plugId) { remove_connection = connection; break; } } if (remove_connection != null) { Node input_node = m_nodeGraphModel.GetNodeFromID(remove_connection.m_inputNodeId); if (m_currentSelectedInPlug != null) { m_currentSelectedOutPlug = out_plug; CreateConnection(); } else { m_currentSelectedInPlug = input_node.m_inputPlug; m_currentSelectedOutPlug = null; } if (m_currentSelectedInPlug != null && input_node.m_inputPlug.m_plugId == m_currentSelectedInPlug.m_plugId) { m_nodeGraphModel.RemoveConnection(remove_connection.m_id); } return; } // no connection on the plug yet m_currentSelectedOutPlug = out_plug; if (m_currentSelectedInPlug != null) { if (m_currentSelectedInPlug.m_nodeId != m_currentSelectedOutPlug.m_nodeId) { CreateConnection(); } ClearConnectionSelection(); } }
public void Start() { XDoc authxdoc = CreateDefaultXml(); string filename = System.IO.Path.GetTempFileName() + ".xml"; authxdoc.Save(filename); Plug p = Utils.BuildPlugForAdmin(); string serviceid = GetServiceIDBySID(p, SID); DreamMessage msg = null; XDoc xdoc = null; if (serviceid == null) { xdoc = new XDoc("service") .Elem("sid", SID) .Elem("uri", string.Empty) .Elem("type", "auth") .Elem("description", Description) .Elem("status", "enabled") .Elem("local", "true") .Elem("init", "native") .Start("config") .Start("value").Attr("key", "xmlauth-path").Value(filename).End() .End(); msg = p.At("site", "services").Post(DreamMessage.Ok(xdoc)); Assert.AreEqual(DreamStatus.Ok, msg.Status); serviceid = msg.ToDocument()["@id"].AsText; msg = p.At("site", "services", serviceid, "start").Post(); Assert.AreEqual(DreamStatus.Ok, msg.Status); } else { msg = p.At("site", "services", serviceid, "stop").Post(); Assert.AreEqual(DreamStatus.Ok, msg.Status); msg = p.At("site", "services", serviceid).Get(); Assert.AreEqual(DreamStatus.Ok, msg.Status); xdoc = msg.ToDocument(); xdoc["config/value[@key='xmlauth-path']"].ReplaceValue(filename); msg = p.At("site", "services", serviceid).Put(xdoc); Assert.AreEqual(DreamStatus.Ok, msg.Status); msg = p.At("site", "services", serviceid, "start").PostAsync().Wait(); Assert.AreEqual(DreamStatus.Ok, msg.Status); } }
//--- Constructors --- /// <summary> /// Create new client instance /// </summary> /// <param name="config">Client configuration.</param> /// <param name="timerFactory">Timer factory.</param> public AmazonS3Client(AmazonS3ClientConfig config, TaskTimerFactory timerFactory) { _config = config; _bucketPlug = Plug.New(_config.S3BaseUri) .WithS3Authentication(_config.PrivateKey, _config.PublicKey) .WithTimeout(_config.Timeout) .At(_config.Bucket); _rootPlug = _bucketPlug; if(!string.IsNullOrEmpty(_config.RootPath)) { _keyRootParts = _config.RootPath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries); if(_keyRootParts != null && _keyRootParts.Any()) { _rootPlug = _rootPlug.At(_keyRootParts); } } _expirationEntries = new ExpiringHashSet<string>(timerFactory); _expirationEntries.EntryExpired += OnDelete; }
public void testPlugCreateInvalidPower() { Plug plug = new Plug { power = -20, type = PlugType.CCS }; var validationResults = new List <ValidationResult>(); var actual = Validator.TryValidateObject(plug, new ValidationContext(plug), validationResults, true); Assert.AreEqual(1, validationResults.Count); var msg = validationResults[0]; Assert.AreEqual("power", msg.MemberNames.ElementAt(0)); }
public void Result_timeout_superceeds_plug_timeout_and_results_in_RequestConnectionTimeout() { MockPlug.Register(new XUri("mock://mock"), (plug, verb, uri, request, response) => { Thread.Sleep(TimeSpan.FromSeconds(10)); response.Return(DreamMessage.Ok()); }); var stopwatch = Stopwatch.StartNew(); var r = Plug.New(MockPlug.DefaultUri) .WithTimeout(TimeSpan.FromSeconds(20)) .InvokeEx(Verb.GET, DreamMessage.Ok(), new Result <DreamMessage>(1.Seconds())).Block(); stopwatch.Stop(); Assert.LessOrEqual(stopwatch.Elapsed.Seconds, 2); Assert.IsFalse(r.HasTimedOut); Assert.IsFalse(r.HasException); Assert.AreEqual(DreamStatus.RequestConnectionTimeout, r.Value.Status); }
void ReleasePlug(Collider plug_connector) { if (picked_plug == null) { return; } PlugConnector con = plug_connector.GetComponent <PlugConnector>(); if (con == null || !con.IsFree()) { return; } picked_plug.transform.position = con.transform.position - main_board.forward * plug_distance; picked_plug.Connect(con); picked_plug = null; audioSource.PlayOneShot(plug_out_sound); }
public void RequestMessage_via_http_is_closed_at_end_of_request() { var recipient = _hostinfo.CreateMockService(); DreamMessage captured = null; recipient.Service.CatchAllCallback = (context, request, response) => { captured = request; response.Return(DreamMessage.Ok()); }; var requestMsg = DreamMessage.Ok(MimeType.TEXT, "foo"); var recipientUri = recipient.AtLocalHost.Uri.WithScheme("ext-http"); Plug.New(recipientUri).Post(requestMsg); Assert.IsNotNull(captured, "did not capture a message in mock service"); Assert.IsTrue(captured.IsClosed, "captured message was not closed"); Assert.IsTrue(requestMsg.IsClosed, "sent message is not closed"); }
public void GetPdf() { // Log in as ADMIN Plug p = Utils.BuildPlugForAdmin(); // Create a page string id = null; string path = null; DreamMessage msg = PageUtils.CreateRandomPage(p, out id, out path); // Retrieve PDF conversion of page msg = p.At("pages", id, "pdf").Get(); Assert.AreEqual(DreamStatus.Ok, msg.Status, "PDF retrieval failed"); // Delete the page PageUtils.DeletePageByID(p, id, true); }
public void TestDeleteOfLeafNode() { // 1. Build a page tree // (2) Assert page A/B/C was created // 3. Delete page A/B/C // (4) Assert page A/B/C is no longer alive Plug p = Utils.BuildPlugForAdmin(); string baseTreePath = PageUtils.BuildPageTree(p); DreamMessage msg = PageUtils.GetPage(p, baseTreePath + "/A/B/C"); Assert.AreEqual("C", msg.ToDocument()["//title"].Contents); msg = PageUtils.DeletePageByName(p, baseTreePath + "/A/B/C", false); msg = PageUtils.GetPage(p, baseTreePath + "/A/B/C"); Assert.AreEqual(DreamStatus.NotFound, msg.Status); }
public void Calling_service_to_service_with_public_uri_sets_host_header() { string receivedHost = null; _service1.Service.CatchAllCallback = delegate(DreamContext context, DreamMessage request, Result <DreamMessage> r) { var r2 = Plug.New(_service2.AtLocalHost.Uri.WithHost("foo").WithPort(80)).Get(); r.Return(DreamMessage.Ok()); }; _service2.Service.CatchAllCallback = delegate(DreamContext context, DreamMessage request, Result <DreamMessage> r) { receivedHost = request.Headers.Host; r.Return(DreamMessage.Ok()); }; var response = _service1.AtLocalHost.GetAsync().Wait(); Assert.IsTrue(response.IsSuccessful); Assert.AreEqual("foo", receivedHost); }
public void ConnectPlug(Plug pPlug) { if (_joint == null) { pPlug.Body.position = _plugPosition.position; pPlug.Body.rotation = _plugPosition.rotation.eulerAngles.z; pPlug.Body.velocity = Vector3.zero; _joint = gameObject.AddComponent <FixedJoint2D>(); _joint.enableCollision = true; _joint.autoConfigureConnectedAnchor = true; _joint.anchor = new Vector2(_plugOffset, 0.0f); _joint.connectedBody = pPlug.Body; _joint.breakForce = _breakForce; _joint.enabled = true; } }
private async void HandleSampleMessage(IWebSocketConnection socket, string[] messageWords) { PowerUsageSample newSample = new PowerUsageSample(Convert.ToDouble(messageWords[1]), Convert.ToDouble(messageWords[2])); // get plug by mac and add the new sample using (ILifetimeScope scope = Program.Container.BeginLifetimeScope()) { SmartSwitchDbContext context = scope.Resolve <SmartSwitchDbContext>(); Plug currentPlug = await context.Plugs.FindAsync(GetMac(socket)); if (currentPlug != null) // if the plug is owned { currentPlug.Samples.Add(newSample); await context.SaveChangesAsync(); } } }
public static void Validate(XUri host) { XDoc license; try { DreamMessage response = Plug.New(host).At("@api", "deki", "license").Get(); // make sure the response is application/xml if (!response.ContentType.Match(MimeType.XML)) { throw new DekiLicenseException(DekiLicenseException.ReasonKind.INVALID_RESPONSE, string.Format("Server returned an invalid license document. Expected application/xml, but received {0}.", response.ContentType.FullType)); } license = response.ToDocument(); } catch (DreamResponseException e) { string message = null; // check status code of response switch (e.Response.Status) { case DreamStatus.MethodNotAllowed: case DreamStatus.NotFound: throw new DekiLicenseException(DekiLicenseException.ReasonKind.NO_LICENSE_FOUND, string.Format("Server did not return license information for '{0}'.", host)); case DreamStatus.ServiceUnavailable: throw new DekiLicenseException(DekiLicenseException.ReasonKind.NO_LICENSE_FOUND, string.Format("Server at '{0}' appears to be down.", host)); } // check if response contains an XML document if (e.Response.ContentType.IsXml) { XDoc doc = e.Response.ToDocument(); if (doc.HasName("exception") || doc.HasName("error")) { message = doc["message"].AsText; } } // use respons document by default if (message == null) { message = (e.Response != null) ? e.Response.ToText() : "No response returned"; } throw new DekiLicenseException(DekiLicenseException.ReasonKind.INVALID_RESPONSE, string.Format("An error occurred while attempting to connect to '{0}'. {2} (status {1}).", host, (int)e.Response.Status, message)); } Validate(host, license); }
public static DreamMessage UploadRandomImage(Plug p, string pageid, out string fileid, out string filename) { filename = Utils.GenerateUniqueName() + ".png"; System.Drawing.Bitmap pic = new System.Drawing.Bitmap(100, 100); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(pic)) g.DrawRectangle(System.Drawing.Pens.Blue, 10, 10, 80, 80); System.IO.MemoryStream stream = new System.IO.MemoryStream(); pic.Save(stream, System.Drawing.Imaging.ImageFormat.Png); p = p.At("pages", pageid, "files", "=" + filename).WithQuery("description=random image"); DreamMessage msg = p.Put(DreamMessage.Ok(MimeType.PNG, stream.ToArray())); Assert.AreEqual(DreamStatus.Ok, msg.Status); fileid = msg.ToDocument()["@id"].AsText; return(msg); }
public void GetGroupByName() { // 1. Create a group // 2. Retrieve a group by name // (3) Assert group name in response matches generated name Plug p = Utils.BuildPlugForAdmin(); string id = null; string name = null; DreamMessage msg = UserUtils.CreateRandomGroup(p, out id, out name); msg = p.At("groups", "=" + name).Get(); Assert.AreEqual(DreamStatus.Ok, msg.Status, "Group retrival failed"); Assert.IsTrue(msg.ToDocument()["groupname"].AsText == name, "Group name in response does not match generated group name!"); }
public static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Need socket id and file-name as an argument."); return; } uint socket_id = UInt32.Parse(args[0]); string filename=args[1]; Console.WriteLine("filename="+filename); Console.WriteLine("using socket "+socket_id); // Glib.Thread.Init(); Gdk.Threads.Init(); Application.Init(); Gdk.Threads.Enter(); try { Plug plug= new Plug(socket_id); Fixed fixed1 = new Fixed(); fixed1.Put(new Label("File: \""+filename+"\""), 10, 10); fixed1.Put(new Entry("HELLO"), 10, 50); fixed1.Put(new Entry("World"), 10, 100); fixed1.ShowAll(); plug.Add(fixed1); plug.ShowAll(); Console.WriteLine("app is running.."); Application.Run(); } finally { Gdk.Threads.Leave(); } Console.WriteLine("Done!"); }
public void RemoveDestinationPlug(Plug plug) { m_destinationPlugs.Remove(plug); }
Yield IPlugEndpoint.Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response) { _env.UpdateInfoMessage(_sourceInternal, null); Result<DreamMessage> res = new Result<DreamMessage>(response.Timeout); _env.SubmitRequestAsync(verb, uri, null, request, res); yield return res; response.Return(res); }
public void RegisterDestinationPlug(Plug plug) { m_destinationPlugs.Add(plug); }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType<Foo>().As<IFoo>().RequestScoped(); _hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.None)); _hostInfo.Host.Self.At("load").With("name", "test.mindtouch.dream").Post(DreamMessage.Ok()); var config = new XDoc("config") .Elem("path", "test") .Elem("sid", "http://services.mindtouch.com/dream/test/2010/07/featuretestserver"); DreamMessage result = _hostInfo.LocalHost.At("host", "services").With("apikey", _hostInfo.ApiKey).Post(config, new Result<DreamMessage>()).Wait(); Assert.IsTrue(result.IsSuccessful, result.ToText()); _plug = Plug.New(_hostInfo.LocalHost.Uri.WithoutQuery()).At("test"); _blueprint = _plug.At("@blueprint").Get().ToDocument(); }
private bool WaitFor(Plug plug, Func<DreamMessage, bool> func, TimeSpan timeout) { var expire = DateTime.Now.Add(timeout); while(expire > DateTime.Now) { var r = plug.GetAsync().Wait(); if(func(r)) { return true; } Thread.Sleep(100); } return false; }
private void AssertFeature(string pattern, Plug plug, XDoc expected) { AssertFeature(pattern, plug.Get(new Result<DreamMessage>()), expected); }
public Yield CreateBadStartChild(DreamContext context, DreamMessage request, Result<DreamMessage> response) { yield return CreateService( "badchild", "sid://mindtouch.com/TestBadStartService", new XDoc("config").Elem("throw", context.GetParam("throw", "false")), new Result<Plug>()).Set(v => _badChild = v); response.Return(DreamMessage.Ok()); yield break; }
public void Init() { _hostInfo = DreamTestHelper.CreateRandomPortHost(); _hostInfo.Host.Self.At("load").With("name", "test.mindtouch.dream").Post(DreamMessage.Ok()); var config = new XDoc("config") .Elem("path", "test") .Elem("sid", "sid://mindtouch.com/DreamContextTestService"); DreamMessage result = _hostInfo.LocalHost.At("host", "services").With("apikey", _hostInfo.ApiKey).PostAsync(config).Wait(); Assert.IsTrue(result.IsSuccessful, result.ToText()); _plug = Plug.New(_hostInfo.LocalHost.Uri.WithoutQuery()).At("test"); DreamContextTestService.ContextVar = null; }
private DreamServiceInfo(DreamServiceInfo info, DreamCookieJar cookies) { _internalSetCookie = info._internalSetCookie; _privateSetCookie = info._privateSetCookie; AtLocalHost = info.AtLocalHost.WithCookieJar(cookies); }
public Yield CreateBadChild(DreamContext context, DreamMessage request, Result<DreamMessage> response) { yield return CreateService("badchild", "sid://mindtouch.com/TestBadStopService", null, new Result<Plug>()).Set(v => _badChild = v); response.Return(DreamMessage.Ok()); yield break; }
public void Init() { _hostInfo = DreamTestHelper.CreateRandomPortHost(); _hostInfo.Host.Self.At("load").With("name", "test.mindtouch.dream").Post(DreamMessage.Ok()); var config = new XDoc("config") .Elem("path", "test") .Elem("sid", "http://services.mindtouch.com/dream/test/2010/07/featuretestserver"); DreamMessage result = _hostInfo.LocalHost.At("host", "services").With("apikey", _hostInfo.ApiKey).PostAsync(config).Wait(); Assert.IsTrue(result.IsSuccessful, result.ToText()); _plug = Plug.New(_hostInfo.LocalHost.Uri.WithoutQuery()).At("test"); _blueprint = _plug.At("@blueprint").Get().ToDocument(); }
private void CreateSecondPrivateStorageServiceProxy() { _hostInfo.Host.Self.At("services").Post( new XDoc("config") .Elem("class", typeof(TestServiceWithPrivateStorage).FullName) .Elem("path", TEST_PATH + "2")); _log.Debug("created second storage service"); testService = Plug.New(_hostInfo.Host.LocalMachineUri).At(TEST_PATH + "2"); }
//--- Methods --- protected override Yield Start(XDoc config, Result result) { yield return Coroutine.Invoke(base.Start, config, new Result()); yield return CreateService("inner", "http://services.mindtouch.com/dream/test/2007/03/sample-inner", new XDoc("config").Start("prologue").Attr("name", "dummy").Value("p3").End().Start("epilogue").Attr("name", "dummy").Value("e3").End(), new Result<Plug>()).Set(v => _inner = v); result.Return(); }
public void Send(Plug jack, float[] values) { m_incomingJackValues[jack] = values; SetDirty(); }
//--- Constructors --- internal DreamServiceInfo(DreamHostInfo hostInfo, string path, XDoc serviceResponse) { _internalSetCookie = serviceResponse["internal-key/set-cookie"]; _privateSetCookie = serviceResponse["private-key/set-cookie"]; AtLocalHost = Plug.New(hostInfo.LocalHost.At(path)); }
private void CreatePrivateStorageServiceProxy() { _hostInfo.Host.Self.At("load").With("name", "test.mindtouch.storage").Post(DreamMessage.Ok()); _hostInfo.Host.Self.At("services").Post( new XDoc("config") .Elem("class", typeof(TestServiceWithPrivateStorage).FullName) .Elem("path", TEST_PATH)); testService = Plug.New(_hostInfo.Host.LocalMachineUri).At(TEST_PATH); }
private void AssertFeature(string pattern, Plug plug) { AssertFeature(pattern, plug, null); }
protected override Yield Stop(Result result) { if(_inner != null) { yield return _inner.DeleteAsync().CatchAndLog(_log); _inner = null; } yield return Coroutine.Invoke(base.Stop, new Result()); result.Return(); }
internal MockServiceInfo(DreamHostInfo hostInfo, string path, MockService service) { AtLocalMachine = Plug.New(hostInfo.Host.LocalMachineUri.At(path)); AtLocalHost = Plug.New(hostInfo.LocalHost.At(path)); Service = service; }