예제 #1
0
        public void CanHandleInternalServerErrorHttpStatusWorldInstanceResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new WorldApi();
            var result = api.GetInstance("some world id", "some instance id").Result;

            result.Should().BeNull();
        }
예제 #2
0
        public void CanHandleValidWorldInstanceResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("id", "some instance id"),
                                                   new JProperty("private", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some private user id"),
                                                                         new JProperty("username", "some private username"),
                                                                         new JProperty("displayName", "some private display name"),
                                                                         new JProperty("currentAvatarImageUrl", "https://unit.test/privateAvatarImageUrl.jpg"),
                                                                         new JProperty("currentAvatarThumbnailImageUrl", "https://unit.test/privateAvatarThumbnailImageUrl.jpg"),
                                                                         new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                                         new JProperty("developerType", "some private developer type"),
                                                                         new JProperty("status", "some private status"),
                                                                         new JProperty("statusDescription", "some private status description"),
                                                                         new JProperty("networkSessionId", "some private network session id")))),
                                                   new JProperty("friends", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some friend user id"),
                                                                         new JProperty("username", "some friend username"),
                                                                         new JProperty("displayName", "some friend display name"),
                                                                         new JProperty("currentAvatarImageUrl", "https://unit.test/friendAvatarImageUrl.jpg"),
                                                                         new JProperty("currentAvatarThumbnailImageUrl", "https://unit.test/friendAvatarThumbnailImageUrl.jpg"),
                                                                         new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                                         new JProperty("developerType", "some friend developer type"),
                                                                         new JProperty("status", "some friend status"),
                                                                         new JProperty("statusDescription", "some friend status description"),
                                                                         new JProperty("networkSessionId", "some friend network session id")))),
                                                   new JProperty("users", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some user id"),
                                                                         new JProperty("username", "some username"),
                                                                         new JProperty("displayName", "some display name"),
                                                                         new JProperty("currentAvatarImageUrl", "https://unit.test/currentAvatarImageUrl.jpg"),
                                                                         new JProperty("currentAvatarThumbnailImageUrl", "https://unit.test/currentAvatarThumbnailImageUrl.jpg"),
                                                                         new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                                         new JProperty("developerType", "some developer type"),
                                                                         new JProperty("status", "some status"),
                                                                         new JProperty("statusDescription", "some status description"),
                                                                         new JProperty("networkSessionId", "some network session id")))),
                                                   new JProperty("name", "some name")));

            var api    = new WorldApi();
            var result = api.GetInstance("some world id", "some instance id").Result;

            result.id.Should().Be("some instance id");
            result.privateUsers.Should().HaveCount(1);
            result.privateUsers[0].id.Should().Be("some private user id");
            result.privateUsers[0].username.Should().Be("some private username");
            result.privateUsers[0].displayName.Should().Be("some private display name");
            result.privateUsers[0].currentAvatarImageUrl.Should().Be("https://unit.test/privateAvatarImageUrl.jpg");
            result.privateUsers[0].currentAvatarThumbnailImageUrl.Should().Be("https://unit.test/privateAvatarThumbnailImageUrl.jpg");
            result.privateUsers[0].tags.Should().HaveCount(2);
            result.privateUsers[0].tags[0].Should().Be("tag 1");
            result.privateUsers[0].tags[1].Should().Be("tag 2");
            result.privateUsers[0].developerType.Should().Be("some private developer type");
            result.privateUsers[0].status.Should().Be("some private status");
            result.privateUsers[0].statusDescription.Should().Be("some private status description");
            result.privateUsers[0].networkSessionId.Should().Be("some private network session id");
            result.friends.Should().HaveCount(1);
            result.friends[0].id.Should().Be("some friend user id");
            result.friends[0].username.Should().Be("some friend username");
            result.friends[0].displayName.Should().Be("some friend display name");
            result.friends[0].currentAvatarImageUrl.Should().Be("https://unit.test/friendAvatarImageUrl.jpg");
            result.friends[0].currentAvatarThumbnailImageUrl.Should().Be("https://unit.test/friendAvatarThumbnailImageUrl.jpg");
            result.friends[0].tags.Should().HaveCount(2);
            result.friends[0].tags[0].Should().Be("tag 1");
            result.friends[0].tags[1].Should().Be("tag 2");
            result.friends[0].developerType.Should().Be("some friend developer type");
            result.friends[0].status.Should().Be("some friend status");
            result.friends[0].statusDescription.Should().Be("some friend status description");
            result.friends[0].networkSessionId.Should().Be("some friend network session id");
            result.users.Should().HaveCount(1);
            result.users[0].id.Should().Be("some user id");
            result.users[0].username.Should().Be("some username");
            result.users[0].displayName.Should().Be("some display name");
            result.users[0].currentAvatarImageUrl.Should().Be("https://unit.test/currentAvatarImageUrl.jpg");
            result.users[0].currentAvatarThumbnailImageUrl.Should().Be("https://unit.test/currentAvatarThumbnailImageUrl.jpg");
            result.users[0].tags.Should().HaveCount(2);
            result.users[0].tags[0].Should().Be("tag 1");
            result.users[0].tags[1].Should().Be("tag 2");
            result.users[0].developerType.Should().Be("some developer type");
            result.users[0].status.Should().Be("some status");
            result.users[0].statusDescription.Should().Be("some status description");
            result.users[0].networkSessionId.Should().Be("some network session id");
            result.name.Should().Be("some name");
        }