Exemplo n.º 1
0
        public void ShoudRunOrderOfLogic()
        {
            var storageHtml = Mock.Create <IStorageHtml>();
            var x1          = new HtmlProduct()
            {
                Domain    = "test.vn",
                ProductId = 123,
                Html      = File.ReadAllText("DataTest/HtmlProductLazada.html")
            };

            Mock.Arrange(() => storageHtml.GetHtml(Arg.IsAny <long>())).Returns(x1);
            var storagePropertiesProduct = Mock.Create <IStoragePropertiesProduct>();

            Mock.Arrange(() => storagePropertiesProduct.SaveProperiesProduct(Arg.IsAny <PropertyProduct>()));

            var parser = Mock.Create <IParser>();

            Mock.Arrange(() => parser.ParseData(Arg.IsAny <HtmlDocument>())).Returns(new PropertyProduct()
            {
                ProductId = 1
            });

            //Act
            HandlerParseProperties hander = new HandlerParseProperties(storageHtml, storagePropertiesProduct, parser);

            hander.ProcessJob(100);

            //Assert
            Mock.Assert(parser);
            Mock.Assert(storageHtml);
            Mock.Assert(storagePropertiesProduct);
        }
Exemplo n.º 2
0
        public void InsertDocument(HtmlProduct htmlProduct)
        {
            var bsonDocument = Builders <BsonDocument> .Filter.Eq("_id", htmlProduct._id);

            this._colHtmlProduct.UpdateOne(bsonDocument, htmlProduct.ToBsonDocument(), new UpdateOptions()
            {
                IsUpsert = true
            });
        }
Exemplo n.º 3
0
        public void SaveHtml(HtmlProduct htmlProduct)
        {
            string queryDelete = "{product_id:NumberLong(" + htmlProduct.ProductId + ")}";

            //htmlProduct.HtmlZip = (new WSS.LibExtra.UtilZipFile()).ZipOfEncode(htmlProduct.Html);
            //htmlProduct.HtmlZip = (new WSS.LibExtra.UtilZipFile()).UnzipOfEncode(htmlProduct.Html);
            //this._collection.DeleteMany(queryDelete);
            //this._collection.InsertOne(htmlProduct);

            if (producerBasic != null)
            {
            }
        }
Exemplo n.º 4
0
        public void SaveHtmlProduct()
        {
            HtmlProduct doc1 = new HtmlProduct()
            {
                Domain    = "test.data",
                Html      = "testHtm",
                ProductId = 123,
                _id       = new ObjectId(MD5.CalculateMD5Hash1("123"))
            };

            MongoAdapter mongoAdapter = MongoAdapter.Instance();

            mongoAdapter.InsertDocument(doc1);
        }