public async Task RealEstate_Get_ResourceDoesNotExist_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.NotFound, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = await Client.RealEstates.GetAsync("test");
            });
        }
        public async Task RealEstate_Update_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return(new HttpStubResponse {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.RealEstates.UpdateAsync(new ApartmentRent());
            });
        }
Exemple #3
0
        public async Task Auth_GetAccessToken_ErrorThrowsException()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.NotFound, ResponseObject = new Messages()
                });
            });

            Connection.RequestToken       = "request_token";
            Connection.RequestTokenSecret = "request_secret";

            await AssertEx.ThrowsAsync <IS24Exception>(async() => await Connection.GetAccessToken("verifier"));
        }
Exemple #4
0
        public async Task Contact_Get_ResourceDoesNotExist_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return(new HttpStubResponse {
                    StatusCode = HttpStatusCode.NotFound, ResponseObject = new messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var contact = await Client.Contacts.GetAsync("test");
            });
        }
Exemple #5
0
        public async Task Contact_Update_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return(new HttpStubResponse {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.Contacts.UpdateAsync(new RealtorContactDetails());
            });
        }
Exemple #6
0
        public async Task Attachment_Get_ResourceDoesNotExist_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return(new HttpStubResponse {
                    StatusCode = HttpStatusCode.NotFound, ResponseObject = new messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var a = await realEstate.Attachments.GetAsync("x");
            });
        }
Exemple #7
0
        public async Task Attachment_Create_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return(new HttpStubResponse {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await realEstate.Attachments.CreateAsync(new Picture {
                    id = 1, idSpecified = true
                }, @"..\..\test.jpg");
            });
        }
        public async Task Attachment_Get_ResourceDoesNotExist_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.NotFound, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 1
                }, Client.Connection);
                var a = await re.Attachments.GetAsync("x");
            });
        }
        public async Task OnTopPlacement_CreateWithId_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.POST, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/1/topplacement", RestClient.BuildUri(r).ToString());
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.ERROR_RESOURCE_VALIDATION, MessageProperty = "Error while validating input for the resource. [MESSAGE: topplacement for this real estate is not possible:Not allowed to perform ontop for unpublished realestate (#1).]"
                                } }
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.TopPlacements.CreateAsync("1");
            });
        }
        public async Task OnTopPlacement_Remove_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.DELETE, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/1/topplacement", RestClient.BuildUri(r).ToString());
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.ERROR_RESOURCE_VALIDATION, MessageProperty = "Error while validating input for the resource. [MESSAGE: topplacement for realestate with id='1' can not be deleted before 2014-01-29T13:17:10.000+01:00]"
                                } }
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.TopPlacements.RemoveAsync("1");
            });
        }
        public async Task RealEstateProject_RemoveAll_RequestsCorrectResource()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.DELETE, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestateproject/4711/realestateprojectentry", RestClient.BuildUri(r).ToString());
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_DELETED, MessageProperty = "" } } };
            }).ThenWith(r =>
            {
                return new RestResponseStub { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await Client.RealEstateProjects.RemoveAsync(4711);
            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                await Client.RealEstateProjects.RemoveAsync(4712);
            });
        }
        public async Task Attachment_Create_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.CreateAsync(new Picture {
                    Id = 1
                }, @"..\..\..\test.jpg");
            });
        }
        public async Task Attachment_CreateLink_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.CreateAsync(new Link {
                    Url = "http://www.example.com"
                });
            });
        }
        public async Task AttachmentsOrder_Update_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.AttachmentsOrder.UpdateAsync(new AttachmentsOrder.List {
                    AttachmentId = { 3, 2, 1 }
                });
            });
        }
        public async Task Attachment_CreateVideo_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    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");
            });
        }
        public async Task Publish_Publish_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.GET, r.Method);
                return(new PublishObjects {
                    PublishObject = { }
                });
            }).ThenWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.Publish.PublishAsync(new ApartmentRent {
                    Id = 4711
                });
            });
        }
Exemple #17
0
        public async Task Publish_Publish_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                Assert.Equal("GET", m);
                return(new publishObjects {
                    publishObject = new PublishObject[] { }
                });
            }).ThenWith(m =>
            {
                return(new HttpStubResponse {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.Publish.PublishAsync(new ApartmentRent {
                    id = 4711, idSpecified = true
                });
            });
        }
        public async Task OnTopPlacement_Get_CallSucceeds()
        {
            RestClient.RespondWith(r =>
            {
                return(new Topplacements
                {
                    Topplacement =
                    {
                        new Topplacement
                        {
                            Realestateid = "1",
                            MessageCode = MessageCode.MESSAGE_OPERATION_SUCCESSFUL,
                            Message = "toplisted",
                            ServicePeriod = new DateRange{
                                DateFrom = new DateTime(2014, 1, 1), DateTo = new DateTime(2014, 2, 1)
                            },
                            ExternalId = "ext1"
                        }
                    }
                });
            }).ThenWith(r =>
            {
                return(new Topplacements
                {
                    Topplacement =
                    {
                        new Topplacement
                        {
                            Realestateid = "2",
                            MessageCode = MessageCode.ERROR_REQUESTED_DATA_NOT_FOUND,
                            Message = "not toplisted"
                        }
                    }
                });
            }).ThenWith(r =>
            {
                return(new Topplacements
                {
                    Topplacement =
                    {
                        new Topplacement
                        {
                            Realestateid = "3",
                            MessageCode = MessageCode.ERROR_RESOURCE_NOT_FOUND,
                            Message = "resource not found"
                        }
                    }
                });
            });

            var result = await Client.TopPlacements.GetAsync("1");

            var expected = new Topplacement
            {
                Realestateid  = "1",
                MessageCode   = MessageCode.MESSAGE_OPERATION_SUCCESSFUL,
                Message       = "toplisted",
                ServicePeriod = new DateRange {
                    DateFrom = new DateTime(2014, 1, 1), DateTo = new DateTime(2014, 2, 1)
                },
                ExternalId = "ext1"
            };

            AssertEx.Equal(expected, result);

            result = await Client.TopPlacements.GetAsync("2");

            Assert.Null(result);

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                await Client.TopPlacements.GetAsync("3");
            });
        }