Ejemplo n.º 1
0
        public async Task Attachment_CreateVideo_ErrorOccursAtPostAttachment_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                return "ok";
            }).ThenWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var video = new StreamingVideo { Title = "Video" };
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
            });
        }
Ejemplo n.º 2
0
        public async Task Attachment_CreateVideo_CanDeserializeResponse()
        {
            Http.RespondWith(m =>
            {
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                return "ok";
            }).ThenWith(m =>
            {
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var video = new StreamingVideo { Title = "Video" };
            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
            Assert.Equal(4711, video.Id);
            Assert.Equal("xyz", video.VideoId);
        }
Ejemplo n.º 3
0
        public async Task Attachment_CreateVideo_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var video = new StreamingVideo { Title = "Video" };
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
            });
        }
Ejemplo n.º 4
0
        public async Task Attachment_CreateVideo_RequestsCorrectResource()
        {
            Http.RespondWith(m =>
            {
                Assert.Equal("GET", m);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/videouploadticket", Http.Url.AbsoluteUri);
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                Assert.Equal("POST", m);
                Assert.Equal("secret", Http.Parameters.Single(p => p.Name == "auth").Value);
                Assert.Equal("http://www.example.com/test", Http.Url.AbsoluteUri);
                return "ok";
            }).ThenWith(m =>
            {
                Assert.Equal("POST", m);
                var v = new BaseXmlDeserializer().Deserialize<Attachment>(new RestResponse { Content = Http.RequestBody });
                Assert.Equal("xyz", ((StreamingVideo)v).VideoId);
                Assert.Equal("Video", ((StreamingVideo)v).Title);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment", Http.Url.AbsoluteUri);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var video = new StreamingVideo { Title = "Video" };
            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
        }