Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 7d9c579

Browse files
authored
[POI] fix test (#2581)
1 parent 5187749 commit 7d9c579

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

skills/csharp/tests/pointofinterestskill.tests/API/AzureMapsGeoSpatialServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task GetPointOfInterestDetailsTest()
4343
var pointOfInterestList = await service.GetNearbyPointOfInterestListAsync(MockData.Latitude, MockData.Longitude);
4444

4545
var pointOfInterest = await service.GetPointOfInterestDetailsAsync(pointOfInterestList[0]);
46-
Assert.AreEqual(pointOfInterest.PointOfInterestImageUrl, string.Format("https://atlas.microsoft.com/map/static/png?api-version=1.0&layer=basic&style=main&zoom={2}&center={0},{1}&width=440&height=240&pins=default|la15+50|al0.75|cod83b01||{0} {1}&subscription-key={3}", pointOfInterestList[0].Geolocation.Longitude, pointOfInterestList[0].Geolocation.Latitude, 14, MockData.Key));
46+
Assert.AreEqual(pointOfInterest.PointOfInterestImageUrl.Substring(0, 23), "data:image/jpeg;base64,");
4747
}
4848

4949
[TestMethod]

skills/csharp/tests/pointofinterestskill.tests/API/Fakes/MockHttpClientHandlerGen.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System.Linq;
1+
using System.Drawing;
2+
using System.Drawing.Imaging;
3+
using System.IO;
4+
using System.Linq;
25
using System.Net.Http;
36
using System.Threading;
47
using System.Threading.Tasks;
@@ -150,6 +153,24 @@ private void SetHttpMockBehavior(ref Mock<HttpClientHandler> mockClient)
150153
{
151154
Content = new StringContent(this.GetFoursquareParkingCategory()),
152155
});
156+
157+
MemoryStream ms = new MemoryStream();
158+
using (var image = new Bitmap(1, 1))
159+
{
160+
image.SetPixel(0, 0, Color.White);
161+
image.Save(ms, ImageFormat.Png);
162+
}
163+
164+
mockClient
165+
.Protected()
166+
.Setup<Task<HttpResponseMessage>>(
167+
MockData.SendAsync,
168+
ItExpr.Is<HttpRequestMessage>(r => r.RequestUri.ToString().StartsWith("https://atlas.microsoft.com/map/static/png")),
169+
ItExpr.IsAny<CancellationToken>())
170+
.ReturnsAsync(() => new HttpResponseMessage()
171+
{
172+
Content = new ByteArrayContent(ms.ToArray()),
173+
});
153174
}
154175

155176
private string GetAzureMapsPointOfInterest()

0 commit comments

Comments
 (0)