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); }
public void InsertDocument(HtmlProduct htmlProduct) { var bsonDocument = Builders <BsonDocument> .Filter.Eq("_id", htmlProduct._id); this._colHtmlProduct.UpdateOne(bsonDocument, htmlProduct.ToBsonDocument(), new UpdateOptions() { IsUpsert = true }); }
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) { } }
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); }