Ejemplo n.º 1
0
        public void CanHandleInternalServerErrorHttpStatusGetWorldByIdResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new WorldApi();
            var result = api.Get("some world id").Result;

            result.Should().BeNull();
        }
Ejemplo n.º 2
0
        public void CanHandleValidGetWorldByIdResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("id", "some world id"),
                                                   new JProperty("name", "some world name"),
                                                   new JProperty("description", "some world description"),
                                                   new JProperty("featured", false),
                                                   new JProperty("authorId", "some author id"),
                                                   new JProperty("authorName", "some author name"),
                                                   new JProperty("totalLikes", 420),
                                                   new JProperty("totalVisits", 1337),
                                                   new JProperty("capacity", (short)42),
                                                   new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                   new JProperty("releaseStatus", "public"),
                                                   new JProperty("imageUrl", "https://unit.test/imageUrl.jpg"),
                                                   new JProperty("thumbnailImageUrl", "https://unit.test/thumbnailImageUrl.jpg"),
                                                   new JProperty("assetUrl", "https://unit.test/assetUrl.asset"),
                                                   new JProperty("pluginUrl", "https://unit.test/pluginUrl.plugin"),
                                                   new JProperty("unityPackageUrl", "https://unit.test/unityPackageUrl.unityPackage"),
                                                   new JProperty("namespace", "some namespace presumably"),
                                                   new JProperty("unityPackageUpdated", false),
                                                   new JProperty("unityPackages", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some unity package id"),
                                                                         new JProperty("assetUrl", "https://unit.test/1/assetUrl.asset"),
                                                                         new JProperty("pluginUrl", "https://unit.test/1/pluginUrl.plugin"),
                                                                         new JProperty("unityVersion", "7"),
                                                                         new JProperty("unitySortNumber", 9001),
                                                                         new JProperty("assetVersion", 1),
                                                                         new JProperty("platform", "some platform"),
                                                                         new JProperty("created_at", "some date")))),
                                                   new JProperty("isSecure", false),
                                                   new JProperty("isLockdown", false),
                                                   new JProperty("version", 2),
                                                   new JProperty("organization", "some organization"),
                                                   new JProperty("instances", new List <JArray> {
                new JArray("some instance id", 2)
            }),
                                                   new JProperty("occupants", 4)));

            var api    = new WorldApi();
            var result = api.Get("some world id").Result;

            result.id.Should().Be("some world id");
            result.name.Should().Be("some world name");
            result.description.Should().Be("some world description");
            result.featured.Should().BeFalse();
            result.authorId.Should().Be("some author id");
            result.authorName.Should().Be("some author name");
            result.totalLikes.Should().Be(420);
            result.totalVisits.Should().Be(1337);
            result.capacity.Should().Be(42);
            result.tags.Should().HaveCount(2);
            result.tags[0].Should().Be("tag 1");
            result.tags[1].Should().Be("tag 2");
            result.releaseStatus.Should().Be(ReleaseStatus.Public);
            result.imageUrl.Should().Be("https://unit.test/imageUrl.jpg");
            result.thumbnailImageUrl.Should().Be("https://unit.test/thumbnailImageUrl.jpg");
            result.assetUrl.Should().Be("https://unit.test/assetUrl.asset");
            result.pluginUrl.Should().Be("https://unit.test/pluginUrl.plugin");
            result.unityPackageUrl.Should().Be("https://unit.test/unityPackageUrl.unityPackage");
            result.nameSpace.Should().Be("some namespace presumably");
            result.unityPackageUpdated.Should().BeFalse();
            result.unityPackages.Should().HaveCount(1);
            result.unityPackages[0].id.Should().Be("some unity package id");
            result.unityPackages[0].assetUrl.Should().Be("https://unit.test/1/assetUrl.asset");
            result.unityPackages[0].pluginUrl.Should().Be("https://unit.test/1/pluginUrl.plugin");
            result.unityPackages[0].unityVersion.Should().Be("7");
            result.unityPackages[0].unitySortNumber.Should().Be(9001);
            result.unityPackages[0].assetVersion.Should().Be(1);
            result.unityPackages[0].platform.Should().Be("some platform");
            result.unityPackages[0].createdTime.Should().Be("some date");
            result.isSecure.Should().BeFalse();
            result.isLockdown.Should().BeFalse();
            result.version.Should().Be(2);
            result.organization.Should().Be("some organization");
            result.instances.Should().HaveCount(1);
            result.instances[0].id.Should().Be("some instance id");
            result.instances[0].occupants.Should().Be(2);
            result.occupants.Should().Be(4);
        }