예제 #1
0
        public PublicationResult BuildFrom(Publication publication, IJsonSerializer jsonSerializer, string trafficTag, string trafficTagName)
        {
            var publicationResult = new PublicationResult(jsonSerializer);

            publicationResult.PublishableItemData = publicationResult.GetPublishableItemData(publication);
            publicationResult.PublicationData = publicationResult.GetPublicationData(publication, trafficTag,trafficTagName);
            publicationResult.UserData = publicationResult.GetUserData(publication);

            return publicationResult;
        }
예제 #2
0
        public void PublicationResult_Foreign_Currency_Shows_Foreign_Price()
        {
            var publication = new Mock<Publication>();

            publication.Setup(x => x.PublishableItemId).Returns(1);
            publication.Setup(x => x.VehicleType).Returns(1);
            publication.Setup(x => x.VehiclePicQty).Returns(1);
            publication.Setup(x => x.PublicationContactsQty).Returns(1);
            publication.Setup(x => x.VehicleMake).Returns(1);
            publication.Setup(x => x.VehicleMakeText).Returns("Clarin");
            publication.Setup(x => x.VehicleModel).Returns(1);
            publication.Setup(x => x.VehicleModelText).Returns("Juan Carlos Altavista");
            publication.Setup(x => x.VehicleVersion).Returns(1);
            publication.Setup(x => x.VehicleVersionText).Returns("Ricardo Montaner");
            publication.Setup(x => x.VehicleSegment).Returns(1);
            publication.Setup(x => x.VehicleSegmentText).Returns("toda estrella tiene contra");
            publication.Setup(x => x.VehicleLocProv).Returns(1);
            publication.Setup(x => x.VehicleLocProvText).Returns("Guadalajara");
            publication.Setup(x => x.VehicleLocPart).Returns(1);
            publication.Setup(x => x.VehicleLocPartText).Returns("Chihuahua");
            publication.Setup(x => x.VehicleLocLoc).Returns(1);
            publication.Setup(x => x.VehicleLocLocText).Returns("Ya no se me ocurre nada");
            publication.Setup(x => x.VehiclePrice).Returns(40000);
            publication.Setup(x => x.CVehiclePriceCurrency.Symbol).Returns("U$S");
            publication.Setup(x => x.VehiclePriceCurrency).Returns(2);
            publication.Setup(x => x.VehicleYear).Returns(3000);
            publication.Setup(x => x.VehicleKm).Returns(18);
            publication.Setup(x => x.VehicleFuelType).Returns(1);
            publication.Setup(x => x.VehicleFuelTypeText).Returns("Energia Atomica");
            publication.Setup(x => x.VehicleFirstOwner).Returns(false);
            publication.Setup(x => x.VehicleColor).Returns(8);
            publication.Setup(x => x.VehicleColorText).Returns("Octavo color");
            publication.Setup(x => x.PaymentMethod).Returns(1);
            publication.Setup(x => x.PaymentMethodText).Returns("Cabras u ovejas");
            publication.Setup(x => x.SellerComment).Returns("Juan carlos");

            publication.Setup(x => x.EquipmentAttributes).Returns(new List<EquipmentAttr>());

            var result = new PublicationResult();
            result = result.BuildFrom(publication.Object, new JsonSerializer(), string.Empty, string.Empty);

            Assert.IsTrue(result.PublishableItemData["PUBLISHABLE_ITEM_DATA_PRICE"].AttributeValue.Equals("40000"));
            Assert.IsTrue(result.PublishableItemData["PUBLISHABLE_ITEM_DATA_PRICE_CURRENCY_SYMBOL"].AttributeValue.Equals("U$S"));
        }
예제 #3
0
        public string Search(string query)
        {
            var publicationsResult = new List<PublicationResult>();
            var publicationSearch = new PublicationSearch();
            IResults<Publication> result = null;

            if (string.IsNullOrEmpty(query)) return string.Empty;

            if (query.ToLower().Equals("all")) //All indica un search all.
            {
                result = GetResult(string.Empty, string.Empty);
            }
            else
            {
                result = GetResult(query, string.Empty);
            }

            publicationSearch.TotalResults = result.TotalResults;

            var publicationResult = new PublicationResult();
            foreach (var publication in result.ResultList)
            {
                publicationsResult.Add(publicationResult.BuildFrom(publication, JsonSerializer, TrafficTag, TrafficTagName));
            }

            publicationSearch.Results = publicationsResult;
            publicationSearch.Slices = GetPublicationSlice(result);
            if (result.Order.CurrentOrderValue.Contains("index_weight"))
            {
                result.Order.CurrentOrderValue = String.Empty;
            }

            publicationSearch.Order = result.Order;

            publicationSearch.PaginData = new PaginData(result.ActualPage,  result.PageSize,
                                                        result.TotalPages);

            return JsonSerializer.Serialize(publicationSearch, GetKnownTypes());
        }
예제 #4
0
        public string GetPublication(string publicationId)
        {
            var query = QueryOver<Publication>.Property(x => x.PublicationId).WithValue(publicationId).Build();

            var results = IndexService.Query(query);

            var publicationResult = new PublicationResult();

            var publicationsResult = results.Select(publication => publicationResult.BuildFrom(publication, JsonSerializer, TrafficTag, TrafficTagName))
                                            .ToList();

            return JsonSerializer.Serialize(publicationsResult, GetKnownTypes());
        }
예제 #5
0
        public void PublicationResult_Should_Ignore_Repeated_Equipment()
        {
            var publication = new Mock<Publication>();

            publication.Setup(x => x.PublishableItemId).Returns(1);
            publication.Setup(x => x.VehicleType).Returns(1);
            publication.Setup(x => x.VehiclePicQty).Returns(1);
            publication.Setup(x => x.PublicationContactsQty).Returns(1);
            publication.Setup(x => x.VehicleMake).Returns(1);
            publication.Setup(x => x.VehicleMakeText).Returns("Clarin");
            publication.Setup(x => x.VehicleModel).Returns(1);
            publication.Setup(x => x.VehicleModelText).Returns("Juan Carlos Altavista");
            publication.Setup(x => x.VehicleVersion).Returns(1);
            publication.Setup(x => x.VehicleVersionText).Returns("Ricardo Montaner");
            publication.Setup(x => x.VehicleSegment).Returns(1);
            publication.Setup(x => x.VehicleSegmentText).Returns("toda estrella tiene contra");
            publication.Setup(x => x.VehicleLocProv).Returns(1);
            publication.Setup(x => x.VehicleLocProvText).Returns("Guadalajara");
            publication.Setup(x => x.VehicleLocPart).Returns(1);
            publication.Setup(x => x.VehicleLocPartText).Returns("Chihuahua");
            publication.Setup(x => x.VehicleLocLoc).Returns(1);
            publication.Setup(x => x.VehicleLocLocText).Returns("Ya no se me ocurre nada");
            publication.Setup(x => x.VehiclePrice).Returns(40000);
            publication.Setup(x => x.CVehiclePriceCurrency.Symbol).Returns("U$S");
            publication.Setup(x => x.VehiclePriceCurrency).Returns(2);
            publication.Setup(x => x.VehicleYear).Returns(3000);
            publication.Setup(x => x.VehicleKm).Returns(18);
            publication.Setup(x => x.VehicleFuelType).Returns(1);
            publication.Setup(x => x.VehicleFuelTypeText).Returns("Energia Atomica");
            publication.Setup(x => x.VehicleFirstOwner).Returns(false);
            publication.Setup(x => x.VehicleColor).Returns(8);
            publication.Setup(x => x.VehicleColorText).Returns("Octavo color");
            publication.Setup(x => x.PaymentMethod).Returns(1);
            publication.Setup(x => x.PaymentMethodText).Returns("Cabras u ovejas");
            publication.Setup(x => x.SellerComment).Returns("Juan carlos");

            var equipment = new List<EquipmentAttr>
            {
                new EquipmentAttr("Faros Antiniebla", "No se que va acá", "Faros"),
                new EquipmentAttr("Porta Vasos", "Ni idea", "Porta cosas"),
                new EquipmentAttr("Faros Antiniebla", "No se que va acá", "Faros"),
            };

            var equipmentKeys = new List<string>
            {
                "Faros Antiniebla",
                "Porta Vasos",
                "Faros Antiniebla"
            };

            publication.Setup(x => x.EquipmentAttributesKeys).Returns(equipmentKeys);

            publication.Setup(x => x.EquipmentAttributes).Returns(equipment);

            var result = new PublicationResult();

            Assert.DoesNotThrow(() => result.BuildFrom(publication.Object, new JsonSerializer(), string.Empty,
                                                       string.Empty));
        }