public void ImportBlocks() { var obj = new { IsSystem = false, Path = "Test Path", Name = "Test Name", Description = "Test desc", Blocks = new List<dynamic> { new { IsSystem = true, BlockTypeId = 1, Zone = "TestZone", Order = 3, Name = "FooInstance", OutputCacheDuration = 0 } } }; var json = obj.ToJson(); var blockType = BlockType.FromJson( json ); var blocks = blockType.Blocks; Assert.NotNull( blockType ); // TODO: Fix Clone() to include all child objects //Assert.NotNull( blocks ); //Assert.NotEmpty( blocks ); //Assert.Equal( blocks.First().Name, obj.Blocks[0].Name ); }
public override HttpRequestItem BuildRequest() { var url = string.Format(ApiUrls.GetContact, Session.BaseUrl, Session.PassTicket, Session.Skey, Timestamp); var obj = new { Session.BaseRequest }; var req = new HttpRequestItem(HttpMethodType.Post, url) { RawData = obj.ToJson(), ContentType = HttpConstants.JsonContentType }; return req; }
public void Can_parse_ArrayObjects() { var data = new { key = new[] { "value1", "value2" } }; var json = data.ToJson(); Assert.That(json, Is.EqualTo(@"{""key"":[""value1"",""value2""]}")); var value = JsonObject.Parse(json); var dataObjects = value.Get<string[]>("key"); Assert.That(dataObjects[0], Is.EqualTo("value1")); Assert.That(dataObjects[1], Is.EqualTo("value2")); }
public void ShouldImportProperties() { var obj = new { IsSystem = false, Path = "Test Path", Name = "Test Name", Description = "Test desc" }; var json = obj.ToJson(); var blockType = BlockType.FromJson( json ); Assert.AreEqual( obj.Description, blockType.Description ); Assert.AreEqual( obj.IsSystem, blockType.IsSystem ); }