public void Test_Find() { var dateStamp = DateTime.Now; #region Arrange var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 10 }); var tmpPriceList = new PriceListConnector().Get("TST_PR"); #endregion Arrange IPriceConnector connector = new PriceConnector(); var newPrice = new Price() { ArticleNumber = tmpArticle.ArticleNumber, PriceList = tmpPriceList.Code, PriceValue = 100, FromQuantity = 0 }; //Add entries for (var i = 0; i < 5; i++) { newPrice.PriceValue -= 10; newPrice.FromQuantity += 10; connector.Create(newPrice); } var searchSettings = new PriceSearch(); searchSettings.LastModified = dateStamp.AddSeconds(-1); var fullCollection = connector.Find(tmpPriceList.Code, tmpArticle.ArticleNumber, searchSettings); Assert.AreEqual(5 + 1, fullCollection.TotalResources); Assert.AreEqual(5 + 1, fullCollection.Entities.Count); Assert.AreEqual(1, fullCollection.TotalPages); Assert.AreEqual("TST_PR", fullCollection.Entities.First().PriceList); //Apply Limit searchSettings.Limit = 2; var limitedCollection = connector.Find(tmpPriceList.Code, tmpArticle.ArticleNumber, searchSettings); Assert.AreEqual(5 + 1, limitedCollection.TotalResources); Assert.AreEqual(2, limitedCollection.Entities.Count); Assert.AreEqual(3, limitedCollection.TotalPages); //Delete entries foreach (var entry in fullCollection.Entities) { if (entry.FromQuantity == 0) { continue; //base price } connector.Delete(entry.PriceList, entry.ArticleNumber, entry.FromQuantity); } #region Delete arranged resources new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }
public void Test_Find() { #region Arrange var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 10 }); var tmpPriceList = new PriceListConnector().Get("TST_PR") ?? new PriceListConnector().Create(new PriceList() { Code = "TST_PR", Description = "TmpPriceList" }); #endregion Arrange IPriceConnector connector = new PriceConnector(); var newPrice = new Price() { ArticleNumber = tmpArticle.ArticleNumber, PriceList = tmpPriceList.Code, PriceValue = 100, FromQuantity = 0 }; connector.Create(newPrice); //Add entries for (var i = 0; i < 5; i++) { connector.Create(newPrice); newPrice.PriceValue -= 10; newPrice.FromQuantity += 10; } var fullCollection = connector.Find(tmpPriceList.Code, tmpArticle.ArticleNumber); MyAssert.HasNoError(connector); Assert.AreEqual(5, fullCollection.TotalResources); Assert.AreEqual(5, fullCollection.Entities.Count); Assert.AreEqual(1, fullCollection.TotalPages); Assert.AreEqual("TST_PR", fullCollection.Entities.First().PriceList); //Apply Limit connector.Search.Limit = 2; var limitedCollection = connector.Find(tmpPriceList.Code, tmpArticle.ArticleNumber); MyAssert.HasNoError(connector); Assert.AreEqual(5, limitedCollection.TotalResources); Assert.AreEqual(2, limitedCollection.Entities.Count); Assert.AreEqual(3, limitedCollection.TotalPages); //Delete entries foreach (var entry in fullCollection.Entities) { connector.Delete(entry.PriceList, entry.ArticleNumber, entry.FromQuantity); } #region Delete arranged resources new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }