public void Should_serialize_artist_as_expected()
		{
			const string expectedEncodedOutput = "Id=143451&Name=MGMT&AppearsAs=MGMT&Image=http%3A%2F%2Fcdn.7static.com%2Fstatic%2Fimg%2Fartistimages%2F00%2F001%2F434%2F0000143451_150.jpg&Url=http%3A%2F%2Fwww.7digital.com%2Fartist%2Fmgmt%2F%3Fpartner%3D1401";

			var artist = new Artist
			{
				AppearsAs = "MGMT",
				Name = "MGMT",
				Id = 143451,
				Image = "http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg",
				Url = "http://www.7digital.com/artist/mgmt/?partner=1401"
			};

			var actual = _payloadSerializer.Serialize(artist);

			Assert.That(actual, Is.EqualTo(expectedEncodedOutput));
		}
コード例 #2
0
		public void SHould_serialize_artist_as_expected()
		{
			const string expectedXmlOutput = "<?xml version=\"1.0\" encoding=\"utf-8\"?><artist id=\"143451\"><name>MGMT</name><appearsAs>MGMT</appearsAs><image>http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg</image><url>http://www.7digital.com/artist/mgmt/?partner=1401</url></artist>";
			
			var artist = new Artist
				{
					AppearsAs = "MGMT",
					Name = "MGMT",
					Id = 143451,
					Image = "http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg",
					Url = "http://www.7digital.com/artist/mgmt/?partner=1401"
				};

			var xml = _payloadSerializer.Serialize(artist);

			Assert.That(xml, Is.EqualTo(expectedXmlOutput));
		}
コード例 #3
0
		public void Should_serialize_artist_as_expected()
		{
			const string expected = "{\"id\":143451,\"name\":\"MGMT\",\"sortName\":null,\"appearsAs\":\"MGMT\",\"image\":\"http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg\",\"url\":\"http://www.7digital.com/artist/mgmt/?partner=1401\"}";
			
			var artist = new Artist
				{
					AppearsAs = "MGMT",
					Name = "MGMT",
					Id = 143451,
					Image = "http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg",
					Url = "http://www.7digital.com/artist/mgmt/?partner=1401"
				};

			var json = _payloadSerializer.Serialize(artist);

			Assert.That(json, Is.EqualTo(expected));
		}
コード例 #4
0
		public async void Should_allow_you_to_set_a_request_payload_using_an_entity_transferred_as_xml()
		{
			const string expectedOutput = "<?xml version=\"1.0\" encoding=\"utf-8\"?><artist id=\"143451\"><name>MGMT</name><appearsAs>MGMT</appearsAs><image>http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg</image><url>http://www.7digital.com/artist/mgmt/?partner=1401</url></artist>";

			var artist = new Artist
				{
					AppearsAs = "MGMT",
					Name = "MGMT",
					Id = 143451,
					Image = "http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg",
					Url = "http://www.7digital.com/artist/mgmt/?partner=1401"
				};

			var requestBuilder = StubRequestBuilder();
			var httpClient = StubHttpClient();
			var responseParser = StubResponseParser();

			await new FluentApi<Status>(httpClient, requestBuilder, responseParser)
				.WithPayload(artist, PayloadFormat.Xml)
				.Please();

			Expression<Func<Request>> callWithExpectedPayload = () => requestBuilder.BuildRequest(A<RequestData>.That.Matches(x => x.Payload.ContentType == "application/xml" && x.Payload.Data == expectedOutput));

			A.CallTo(callWithExpectedPayload).MustHaveHappened();
		}
コード例 #5
0
		public async void Should_allow_you_to_set_a_request_payload_using_an_entity_transferred_as_json()
		{
			const string expectedOutput = "{\"id\":143451,\"name\":\"MGMT\",\"sortName\":null,\"appearsAs\":\"MGMT\",\"image\":\"http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg\",\"url\":\"http://www.7digital.com/artist/mgmt/?partner=1401\"}";
			
			var artist = new Artist
			{
				AppearsAs = "MGMT",
				Name = "MGMT",
				Id = 143451,
				Image = "http://cdn.7static.com/static/img/artistimages/00/001/434/0000143451_150.jpg",
				Url = "http://www.7digital.com/artist/mgmt/?partner=1401"
			};

			var requestBuilder = StubRequestBuilder();
			var httpClient = StubHttpClient();
			var responseParser = StubResponseParser();

			await new FluentApi<Status>(httpClient, requestBuilder, responseParser)
				.WithPayload(artist, PayloadFormat.Json)
				.Please();

			Expression<Func<Request>> callWithExpectedPayload = () => requestBuilder.BuildRequest(A<RequestData>.That.Matches(x => x.Payload.ContentType == "application/json" && x.Payload.Data == expectedOutput));

			A.CallTo(callWithExpectedPayload).MustHaveHappened();
		}