Ejemplo n.º 1
0
        public void CanHandleValidListRecentWorldsResponse()
        {
            MockHttpMessageHandler.SetResponse(new JArray(
                                                   new JObject(
                                                       new JProperty("id", "some world id"),
                                                       new JProperty("name", "some world name"),
                                                       new JProperty("authorName", "some author name"),
                                                       new JProperty("totalLikes", 420),
                                                       new JProperty("totalVisits", 1337),
                                                       new JProperty("imageUrl", "https://unit.test/imageUrl.jpg"),
                                                       new JProperty("thumbnailImageUrl", "https://unit.test/thumbnailImageUrl.jpg"),
                                                       new JProperty("isSecure", false),
                                                       new JProperty("releaseStatus", "public"),
                                                       new JProperty("organization", "some organization"),
                                                       new JProperty("occupants", 4))));

            var api    = new WorldApi();
            var result = api.Search(endpoint: WorldGroups.Recent).Result;

            result.Should().HaveCount(1);
            result[0].id.Should().Be("some world id");
            result[0].name.Should().Be("some world name");
            result[0].authorName.Should().Be("some author name");
            result[0].totalLikes.Should().Be(420);
            result[0].totalVisits.Should().Be(1337);
            result[0].imageUrl.Should().Be("https://unit.test/imageUrl.jpg");
            result[0].thumbnailImageUrl.Should().Be("https://unit.test/thumbnailImageUrl.jpg");
            result[0].isSecure.Should().BeFalse();
            result[0].releaseStatus.Should().Be(ReleaseStatus.Public);
            result[0].organization.Should().Be("some organization");
            result[0].occupants.Should().Be(4);
        }
Ejemplo n.º 2
0
        public void CanHandleInternalServerErrorHttpStatusListWorldsResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new WorldApi();
            var result = api.Search().Result;

            result.Should().BeNull();
        }