예제 #1
0
 public async void ShouldThrowUnableToDeserializeException()
 {
     var contactJson = StubDataLoader.LoadJsonFile("error.html");
     var service     = new ContactService(new MoxiWorksClient(new StubContextClient(contactJson)));
     await Assert.ThrowsAsync <UnableToDeserializeException>(async() => await service.GetContactAsync("12345678-1234-1234-1234-1234567890ab",
                                                                                                      AgentIdType.AgentUuid, "booyuh"));
 }
        public void ShouldReturnBrand()
        {
            var brandingJson = StubDataLoader.LoadJsonFile("Brands.json");
            var service      = new BrandService(new MoxiWorksClient(new StubContextClient(brandingJson)));
            var fake         = service.GetBrands("moxiworksCompanyid", "agent_id");

            Assert.Single(fake.Item.Brands);
        }
        public void ShouldReturnATask()
        {
            var taskJson = StubDataLoader.LoadJsonFile("Task.json");

            var service  = new TaskService(new MoxiWorksClient(new StubContextClient(taskJson)));
            var response = service.GetTaskAsync("foo", AgentIdType.AgentUuid, "1234", "12345").Result;

            Assert.IsType <Task>(response.Item);
        }
예제 #4
0
        public void ShouldReturnCollectionOfTeamsForACompany()
        {
            var          taskJson = StubDataLoader.LoadJsonFile("Teams.json");
            ITeamService service  = new TeamService(new MoxiWorksClient(new StubContextClient(taskJson)));
            var          response = service.GetCompanyTeamsAync("some_company_id").Result;

            Assert.IsType <List <Team> >(response.Item);
            Assert.True(response.Item.Count == 2);
        }
예제 #5
0
        public void ShouldReturnASoldListing()
        {
            var soldListingJson = StubDataLoader.LoadJsonFile("SoldListing.json");

            ISoldListingService service = new SoldListingService(new MoxiWorksClient(new StubContextClient(soldListingJson)));
            var response = service.GetSoldListingAsync("moxiworks_listing_id", "moxi_works_company_id").Result;

            Assert.IsType <SoldListing>(response.Item);
        }
        public void ShouldReturnCompanyBrand()
        {
            var brandingJson = StubDataLoader.LoadJsonFile("Brand.json");
            var service      = new BrandService(new MoxiWorksClient(new StubContextClient(brandingJson)));
            var fake         = service.GetCompanyBrand("moxiworksCompanyid");

            Assert.Equal(fake.Item.DisplayName, "Company Display Name");
            Assert.Equal(fake.Item.ImageLogo, "http://image.url/image.png");
        }
예제 #7
0
        public void ShouldReturnACollectionOfSoldListings()
        {
            var soldListingsJson = StubDataLoader.LoadJsonFile("SoldListings.json");

            var service  = new SoldListingService(new MoxiWorksClient(new StubContextClient(soldListingsJson)));
            var response = service.GetSoldListingsUpdatedSinceAsync("moxi_works_company_id", AgentIdType.MoxiWorksagentId, "MoxiWorksagentId", DateTime.Now).Result;

            Assert.IsType <SoldListingResults>(response.Item);
            Assert.True(response.Item.Listings.Count == 2);
        }
        public void ShouldReturnAgentWithAlternateOffices()
        {
            var           agentJson = StubDataLoader.LoadJsonFile("Agent.json");
            IAgentService service   = new AgentService(new MoxiWorksClient(new StubContextClient(agentJson)));
            var           response  = service.GetAgentAsync("some_agent_id", "some_company_id").Result;
            var           agent     = response.Item;

            Assert.True(agent.AlternateOffices.Count == 2);
            Assert.Equal(1234, agent.AlternateOffices[0].OfficeId);
        }
예제 #9
0
        public void ShouldReturnATeam()
        {
            var          taskJson = StubDataLoader.LoadJsonFile("Team.json");
            ITeamService service  = new TeamService(new MoxiWorksClient(new StubContextClient(taskJson)));
            var          response = service.GetTeamAsync("some_team_id", "some_company_id").Result;

            Assert.IsType <Team>(response.Item);
            Assert.True(response.Item.Actve);
            Assert.True(response.Item.ZipCode == "91820");
        }
        public void ShouldReturnAnAgent()
        {
            var           agentJson = StubDataLoader.LoadJsonFile("Agent.json");
            IAgentService service   = new AgentService(new MoxiWorksClient(new StubContextClient(agentJson)));
            var           response  = service.GetAgentAsync("some_agent_id", "some_company_id").Result;

            Assert.IsType <Agent>(response.Item);
            Assert.True(response.Item.CreatedTimestamp.HasValue);
            Assert.False(response.Item.DeactivatedTimestamp.HasValue);
        }
        public void ShouldReturnACollectionOfTasksByStartDateEndDate()
        {
            var taskJson = StubDataLoader.LoadJsonFile("Tasks.json");

            var service  = new TaskService(new MoxiWorksClient(new StubContextClient(taskJson)));
            var response = service.GetTaskDueBetweenAsync("foo", AgentIdType.AgentUuid, DateTime.Now, DateTime.Now.AddDays(100), 2).Result;

            Assert.IsType <TaskResponse>(response.Item);
            Assert.Equal(2, response.Item.PageNumber);
            Assert.Equal(2, response.Item.TotalPages);
        }
예제 #12
0
        public void ShouldCreateSomeGalleries()
        {
            var galleryJson = StubDataLoader.LoadJsonFile("Gallery.json");

            var service = new GalleryService(new MoxiWorksClient(new StubContextClient(galleryJson)));

            var response = service.GetAgentGalleries("FooBarBazGoo", AgentIdType.MoxiWorksagentId, "company_id").Result;

            Assert.IsType <GalleryResults>(response.Item);
            Assert.True(response.Item.Galleries.Count == 1);
        }
        public void ShouldDeserializeLargePropertyListing()
        {
            var listingJson = StubDataLoader.LoadJsonFile("LargeListings.json");

            IListingService service = new ListingService(new MoxiWorksClient(new StubContextClient(listingJson)));

            var response = service.GetListingsUpdatedSinceAsync("moxi_works_company_id", AgentIdType.AgentUuid, "some_uuid", DateTime.Now).Result;

            Assert.IsType <ListingResults>(response.Item);
            Assert.True(response.Item.Listings.Count == 1);
        }
        public void ShouldReturnACollectionOfTasksByContactId()
        {
            var taskJson = StubDataLoader.LoadJsonFile("Tasks.json");

            var service  = new TaskService(new MoxiWorksClient(new StubContextClient(taskJson)));
            var response = service.GetTasksDueForContactForAsync("foo", AgentIdType.AgentUuid, "FooBar", 2).Result;

            Assert.IsType <TaskResponse>(response.Item);
            Assert.Equal(2, response.Item.PageNumber);
            Assert.Equal(2, response.Item.TotalPages);
        }
        public void ShouldReturnAnOfficeSync()
        {
            var officeJson = StubDataLoader.LoadJsonFile("office.json");

            IOfficeService service = new OfficeService(new MoxiWorksClient(new StubContextClient(officeJson)));

            var response = service.GetOffice("some_moxiworks_office_id", "some_moxiworks_company_id");

            Assert.IsType <Office>(response.Item);
            Assert.True(response.Item.CreatedTimestamp.HasValue);
            Assert.False(response.Item.DeactivatedTimestamp.HasValue);
        }
        public void ShouldReturnAnAgentWithAccessLevel()
        {
            var           agentJson = StubDataLoader.LoadJsonFile("Agent.json");
            IAgentService service   = new AgentService(new MoxiWorksClient(new StubContextClient(agentJson)));
            var           response  = service.GetAgentWithAccessLevelAsync("some_agent_id", "some_company_id", true).Result;
            var           agent     = response.Item;

            Assert.IsType <Agent>(response.Item);
            Assert.Equal("YERP", agent.AccessLevel);
            Assert.Equal(1.25f, agent.BuyerCommissionRate);
            Assert.Equal(1.25f, agent.SellerCommissionRate);
        }
예제 #17
0
        public void ShouldRunReturnAContactSync()
        {
            var contactJson = StubDataLoader.LoadJsonFile("Contact.json");

            var service = new ContactService(new MoxiWorksClient(new StubContextClient(contactJson)));

            var response = service.GetContact("12345678-1234-1234-1234-1234567890ab",
                                              AgentIdType.AgentUuid, "booyuh");

            Assert.IsType <Contact>(response.Item);
            Assert.True(response.Item.AgentUuid == "12345678-1234-1234-1234-1234567890ab");
        }
        public void ShouldHanldeApiReturnedErrors()
        {
            var json     = StubDataLoader.LoadJsonFile("FailureResponse.json");
            var service  = new TaskService(new MoxiWorksClient(new StubContextClient(json)));
            var response = service.GetTaskAsync("foo", AgentIdType.AgentUuid, "1234", "12345").Result;

            Assert.True((bool?)response.HasErrors);
            Assert.True(response.Errors[0].StatusCode == "3015");
            Assert.Contains(response.Errors[0].Status, "error");
            Assert.Contains(response.Errors[0].Messages[0], "Invalid moxi_works_agent_id");
            Assert.Contains(response.Errors[0].RequestId, "31e1368a-e483-4d55-a1b0-e1e51854693d");
        }
예제 #19
0
        public void ShouldBeAbleToReturnACollectionOfSomePresentationLogs()
        {
            var presentationLogs = StubDataLoader.LoadJsonFile("PesentationLogs.json");

            var service  = new PresentationLogService(new MoxiWorksClient(new StubContextClient(presentationLogs)));
            var response = service.GetPresentationLogsAsync(
                "moxi_works_company_id", DateTime.Now,
                DateTime.Now.AddDays(-3), page_number: 1).Result;


            IsType <PresentationLogResults>(response.Item);
        }
        public void ShouldReturnACollectionOfOfficesSync()
        {
            var officeJson = StubDataLoader.LoadJsonFile("Offices.json");

            IOfficeService service = new OfficeService(new MoxiWorksClient(new StubContextClient(officeJson)));

            var response = service.GetCompanyOffices("some_moxiworks_company_id");

            Assert.IsType <OfficeResults>(response.Item);
            Assert.True(response.Item.Offices.Count == 1);
            Assert.True(response.Item.Offices[0].CreatedTimestamp.HasValue);
            Assert.False(response.Item.Offices[0].DeactivatedTimestamp.HasValue);
        }
예제 #21
0
        public void ShouldHandleSubdomianEmails()
        {
            var contactJson = StubDataLoader.LoadJsonFile("Contact.json");
            var service     = new ContactService(new MoxiWorksClient(new StubContextClient(contactJson)));
            var response    = service.GetContact("12345678-1234-1234-1234-1234567890ab",
                                                 AgentIdType.AgentUuid, "booyuh");
            var contact = response.Item;

            contact.PrimaryEmailAddress = "*****@*****.**";

            response = service.CreateContact(contact);
            Assert.IsType <Contact>(response.Item);
            Assert.True(response.Item.AgentUuid == "12345678-1234-1234-1234-1234567890ab");
        }
        public void ShouldUpdateListingInfo()
        {
            var listingJson = StubDataLoader.LoadJsonFile("listings.json");

            IListingService service = new ListingService(new MoxiWorksClient(new StubContextClient(listingJson)));
            var             update  = new ListingUpdate
            {
                VirtualTourURL = "http://www.example.com"
            };

            var response = service.UpdateListingDataAsync(update).Result;

            Assert.IsType <ListingResults>(response.Item);
            Assert.True(response.Item.Listings.Count == 1);
        }
예제 #23
0
        public async void UnableToDeserializeExceptionShouldContainResponseBody()
        {
            var contactJson = StubDataLoader.LoadJsonFile("error.html");
            var service     = new ContactService(new MoxiWorksClient(new StubContextClient(contactJson)));

            try
            {
                await service.GetContactAsync("12345678-1234-1234-1234-1234567890ab",
                                              AgentIdType.AgentUuid, "booyuh");
            }
            catch (UnableToDeserializeException e)
            {
                Assert.Equal(contactJson, e.Data);
            }
        }
 public void ReturnsByTransaction()
 {
     var buyerTransaction = StubDataLoader.LoadJsonFile("BuyerTransaction.json");
 }
        public void ShouldReturnAListing()
        {
            var listingJson = StubDataLoader.LoadJsonFile("Listing.json");

            IListingService service = new ListingService(new MoxiWorksClient(new StubContextClient(listingJson)));

            var response = service.GetListingAsync("some_moxiworks_listing_id", "some_moxiworks_company_id").Result;

            Assert.IsType <Listing>(response.Item);
            Assert.True(response.Item.LotSizeAcres.HasValue);
            Assert.True(response.Item.BathroomsFull.HasValue);
            Assert.True(response.Item.BathroomsHalf.HasValue);
            Assert.False(response.Item.BathroomsOneQuarter.HasValue);
            Assert.False(response.Item.BathroomsPartial.HasValue);
            Assert.False(response.Item.BathroomsThreeQuarter.HasValue);
            Assert.True(response.Item.BathroomsTotalInteger.HasValue);
            Assert.True(response.Item.BathroomsTotal.HasValue);
            Assert.True(response.Item.BedroomsTotal.HasValue);
            Assert.NotNull(response.Item.PublicTitle);
            Assert.NotNull(response.Item.PublicRemarks);
            Assert.True(response.Item.ModificationTimestamp.HasValue);
            Assert.True(response.Item.InternetAddressDisplayYN.HasValue);
            Assert.True(response.Item.DaysOnMarket.HasValue);
            Assert.True(response.Item.ListingContractDate.HasValue);
            Assert.True(response.Item.CreatedDate.HasValue);
            Assert.NotNull(response.Item.ElementarySchool);
            Assert.True(response.Item.GarageSpaces.HasValue);
            Assert.True(response.Item.WaterfrontYN.HasValue);
            Assert.NotNull(response.Item.HighSchool);
            Assert.False(response.Item.AssociationFee.HasValue);
            Assert.NotNull(response.Item.ListOfficeName);
            Assert.True(response.Item.ListPrice.HasValue);
            Assert.NotNull(response.Item.ListingID);
            Assert.NotNull(response.Item.ListAgentFullName);
            Assert.NotNull(response.Item.ListAgentUUID);
            Assert.NotNull(response.Item.ListAgentOfficeID);
            Assert.NotNull(response.Item.ListAgentMoxiWorksOfficeID);
            Assert.NotNull(response.Item.SecondaryListAgentFullName);
            Assert.NotNull(response.Item.SecondaryListAgentUUID);
            Assert.Null(response.Item.SchoolDistrict);
            Assert.NotNull(response.Item.Address);
            Assert.Null(response.Item.Address2);
            Assert.NotNull(response.Item.City);
            Assert.NotNull(response.Item.CountyOrParish);
            Assert.NotNull(response.Item.Latitude);
            Assert.NotNull(response.Item.Longitude);
            Assert.NotNull(response.Item.StateOrProvince);
            Assert.NotNull(response.Item.PostalCode);
            Assert.Null(response.Item.Community);
            Assert.False(response.Item.LotSizeSquareFeet.HasValue);
            Assert.True(response.Item.InternetEntireListingDisplayYN.HasValue);
            Assert.NotNull(response.Item.MiddleOrJuniorSchool);
            Assert.NotNull(response.Item.ListOfficeAOR);
            Assert.NotNull(response.Item.ListOfficeAORArea);
            Assert.True(response.Item.PoolYN.HasValue);
            Assert.NotNull(response.Item.PropertyType);
            Assert.True(response.Item.TaxAnnualAmount.HasValue);
            Assert.True(response.Item.TaxYear.HasValue);
            Assert.True(response.Item.SingleStory.HasValue);
            Assert.True(response.Item.LivingArea.HasValue);
            Assert.True(response.Item.ViewYN.HasValue);
            Assert.True(response.Item.YearBuilt.HasValue);
            Assert.True(response.Item.OnMarket.HasValue);
            Assert.NotNull(response.Item.Status);
            Assert.NotNull(response.Item.MoxiWorksListingId);
            Assert.True(response.Item.AgentCreatedListing.HasValue);
            Assert.NotNull(response.Item.VirtualTourURL);
            Assert.NotNull(response.Item.ListingURL);
            Assert.IsType <List <PropertyFeatures> >(response.Item.PropertyFeatures);
            Assert.True(response.Item.PropertyFeatures.Count == 4);
            Assert.IsType <List <CompanyListingAttribute> >(response.Item.CompanyListingAttributes);
            Assert.True(response.Item.CompanyListingAttributes.Count == 2);
            Assert.IsType <List <OpenHouse> >(response.Item.OpenHouse);
            Assert.True(response.Item.OpenHouse.Count == 1);
            Assert.IsType <List <ListingImage> >(response.Item.ListingImages);
            Assert.True(response.Item.ListingImages.Count == 1);
            Assert.IsType <ExpandoObject>(response.Item.SharedPartnerData);
            Assert.NotNull(response.Item.SharedPartnerData);
            Assert.True(response.Item.SharedPartnerData.foo == 1);
            foreach (var property in response.Item.SharedPartnerData)
            {
                Assert.NotNull(property.Key);
                Assert.NotNull(property.Value);
                if (property.Value is ExpandoObject propertyValue)
                {
                    foreach (var subproperty in propertyValue)
                    {
                        Assert.NotNull(subproperty.Key);
                        Assert.NotNull(subproperty.Value);
                        //you could keep going or handle the data differently if you wish
                    }
                }
            }
        }