本文整理汇总了C#中IWorkContext.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkContext.Expect方法的具体用法?C# IWorkContext.Expect怎么用?C# IWorkContext.Expect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkContext
的用法示例。
在下文中一共展示了IWorkContext.Expect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public new void SetUp()
{
#region Test data
//color (dropdownlist)
pa1 = new ProductAttribute
{
Id = 1,
Name = "Color",
};
pva1_1 = new ProductVariantAttribute
{
Id = 11,
ProductVariantId = 1,
TextPrompt = "Select color:",
IsRequired = true,
AttributeControlType = AttributeControlType.DropdownList,
DisplayOrder = 1,
ProductAttribute = pa1,
ProductAttributeId = pa1.Id
};
pvav1_1 = new ProductVariantAttributeValue
{
Id = 11,
Name = "Green",
DisplayOrder = 1,
ProductVariantAttribute = pva1_1,
ProductVariantAttributeId = pva1_1.Id
};
pvav1_2 = new ProductVariantAttributeValue
{
Id = 12,
Name = "Red",
DisplayOrder = 2,
ProductVariantAttribute = pva1_1,
ProductVariantAttributeId = pva1_1.Id
};
pva1_1.ProductVariantAttributeValues.Add(pvav1_1);
pva1_1.ProductVariantAttributeValues.Add(pvav1_2);
//custom option (checkboxes)
pa2 = new ProductAttribute
{
Id = 2,
Name = "Some custom option",
};
pva2_1 = new ProductVariantAttribute
{
Id = 21,
ProductVariantId = 1,
TextPrompt = "Select at least one option:",
IsRequired = true,
AttributeControlType = AttributeControlType.Checkboxes,
DisplayOrder = 2,
ProductAttribute = pa2,
ProductAttributeId = pa2.Id
};
pvav2_1 = new ProductVariantAttributeValue
{
Id = 21,
Name = "Option 1",
DisplayOrder = 1,
ProductVariantAttribute = pva2_1,
ProductVariantAttributeId = pva2_1.Id
};
pvav2_2 = new ProductVariantAttributeValue
{
Id = 22,
Name = "Option 2",
DisplayOrder = 2,
ProductVariantAttribute = pva2_1,
ProductVariantAttributeId = pva2_1.Id
};
pva2_1.ProductVariantAttributeValues.Add(pvav2_1);
pva2_1.ProductVariantAttributeValues.Add(pvav2_2);
//custom text
pa3 = new ProductAttribute
{
Id = 3,
Name = "Custom text",
};
pva3_1 = new ProductVariantAttribute
{
Id = 31,
ProductVariantId = 1,
TextPrompt = "Enter custom text:",
IsRequired = true,
AttributeControlType = AttributeControlType.TextBox,
DisplayOrder = 1,
ProductAttribute = pa1,
ProductAttributeId = pa3.Id
};
#endregion
_productAttributeRepo = MockRepository.GenerateMock<IRepository<ProductAttribute>>();
_productAttributeRepo.Expect(x => x.Table).Return(new List<ProductAttribute>() { pa1, pa2, pa3 }.AsQueryable());
_productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1);
_productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2);
//.........这里部分代码省略.........
示例2: SetUp
public new void SetUp()
{
#region Test data
//color (dropdownlist)
ca1 = new CheckoutAttribute
{
Id = 1,
Name= "Color",
TextPrompt = "Select color:",
IsRequired = true,
AttributeControlType = AttributeControlType.DropdownList,
DisplayOrder = 1,
};
cav1_1 = new CheckoutAttributeValue
{
Id = 11,
Name = "Green",
DisplayOrder = 1,
CheckoutAttribute = ca1,
CheckoutAttributeId = ca1.Id,
};
cav1_2 = new CheckoutAttributeValue
{
Id = 12,
Name = "Red",
DisplayOrder = 2,
CheckoutAttribute = ca1,
CheckoutAttributeId = ca1.Id,
};
ca1.CheckoutAttributeValues.Add(cav1_1);
ca1.CheckoutAttributeValues.Add(cav1_2);
//custom option (checkboxes)
ca2 = new CheckoutAttribute
{
Id = 2,
Name = "Custom option",
TextPrompt = "Select custom option:",
IsRequired = true,
AttributeControlType = AttributeControlType.Checkboxes,
DisplayOrder = 2,
};
cav2_1 = new CheckoutAttributeValue
{
Id = 21,
Name = "Option 1",
DisplayOrder = 1,
CheckoutAttribute = ca2,
CheckoutAttributeId = ca2.Id,
};
cav2_2 = new CheckoutAttributeValue
{
Id = 22,
Name = "Option 2",
DisplayOrder = 2,
CheckoutAttribute = ca2,
CheckoutAttributeId = ca2.Id,
};
ca2.CheckoutAttributeValues.Add(cav2_1);
ca2.CheckoutAttributeValues.Add(cav2_2);
//custom text
ca3 = new CheckoutAttribute
{
Id = 3,
Name = "Custom text",
TextPrompt = "Enter custom text:",
IsRequired = true,
AttributeControlType = AttributeControlType.MultilineTextbox,
DisplayOrder = 3,
};
#endregion
_checkoutAttributeRepo = MockRepository.GenerateMock<IRepository<CheckoutAttribute>>();
_checkoutAttributeRepo.Expect(x => x.Table).Return(new List<CheckoutAttribute> { ca1, ca2, ca3 }.AsQueryable());
_checkoutAttributeRepo.Expect(x => x.GetById(ca1.Id)).Return(ca1);
_checkoutAttributeRepo.Expect(x => x.GetById(ca2.Id)).Return(ca2);
_checkoutAttributeRepo.Expect(x => x.GetById(ca3.Id)).Return(ca3);
_checkoutAttributeValueRepo = MockRepository.GenerateMock<IRepository<CheckoutAttributeValue>>();
_checkoutAttributeValueRepo.Expect(x => x.Table).Return(new List<CheckoutAttributeValue> { cav1_1, cav1_2, cav2_1, cav2_2 }.AsQueryable());
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_1.Id)).Return(cav1_1);
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_2.Id)).Return(cav1_2);
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_1.Id)).Return(cav2_1);
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_2.Id)).Return(cav2_2);
var cacheManager = new NopNullCache();
_storeMappingService = MockRepository.GenerateMock<IStoreMappingService>();
_eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
_eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));
_checkoutAttributeService = new CheckoutAttributeService(cacheManager,
_checkoutAttributeRepo,
_checkoutAttributeValueRepo,
_storeMappingService,
_eventPublisher);
//.........这里部分代码省略.........