私はテストを始めたばかりで、MSpec を使用したことがありません。私はチュートリアルを見ましたが、唯一の例は のような「ライト」です1 + 1 should be 2
。この実際の方法をテストする必要がありますが、どこから始めればよいかわかりません。
public ILineItem CreateLineItem(BaseVariationContent sku, int quantityToAdd)
{
var price = sku.GetDefaultPrice();
var parent = sku.GetParentProducts().FirstOrDefault() != null ? _contentLoader.Get<ProductContent>(sku.GetParentProducts().FirstOrDefault()).Code : string.Empty;
return new LineItem
{
Code = sku.Code,
DisplayName = sku.DisplayName,
Description = sku.Description,
Quantity = quantityToAdd,
PlacedPrice = price.UnitPrice.Amount,
ListPrice = price.UnitPrice.Amount,
Created = DateAndTime.Now,
MaxQuantity = sku.MaxQuantity ?? 100,
MinQuantity = sku.MinQuantity ?? 1,
InventoryStatus = sku.TrackInventory ? (int)InventoryStatus.Enabled : (int)InventoryStatus.Disabled,
WarehouseCode = string.Empty, // TODO: Add warehouse id
ParentCatalogEntryId = parent,
};
}
BaseVariationContent
多くのプロパティを持つ単なるクラスであり、拡張機能があります。