本文整理汇总了C#中Product.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Product.Equals方法的具体用法?C# Product.Equals怎么用?C# Product.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.Equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
var expected = new Product(1, "magnit", "Bai Tosho", 2.5m);
var actual = new Product(1, "magnit", "Bai Tosho", 2.5m);
Console.WriteLine(expected.Equals(actual));
}
示例2: Main
static void Main(string[] args)
{
var instance = new BaseImplementation().Implement<ITestInterface>();
for (var i = 0; i < 10; i++)
{
var newP = new Product
{
Customer = new Customer
{
FirstName = "Vitaliy" + i,
LastName = "Lebedev" + i*2
},
Name = "IPad" + i*3,
Id = i
};
var id = instance.Post(newP);
var asyn = instance.Get(id);
var product = asyn.Result;
Console.WriteLine(newP.Equals(product));
}
Console.ReadKey();
}
示例3: ValidateSameProduct
public Boolean ValidateSameProduct(Product product1, Product product2, Boolean autoThrow)
{
if (!product1.Equals(product2))
{
if (autoThrow)
{
Factory.Rollback();
throw new Exception("Transaction between differen products " + product1.Name + ", " + product2.Name + " not allowed.");
}
else
return false;
}
return true;
}
示例4: CallProductOverridedEqualsCheckCurrentNotEqual
public void CallProductOverridedEqualsCheckCurrentNotEqual()
{
Product p1 = new Product("Trek 3500", 500M, 25);
Product p2 = new Product("Trek 7500", 500M, 25);
Product p3 = new Product("Trek 3500", 600M, 25);
Product p4 = new Product("Trek 3500", 500M, 30);
bool resultEquals1 = p1.Equals((object)p2);
bool resultEquals2 = p1.Equals((object)p3);
bool resultEquals3 = p1.Equals((object)p4);
Assert.AreEqual<bool>(false, resultEquals1);
Assert.AreEqual<bool>(false, resultEquals2);
Assert.AreEqual<bool>(false, resultEquals3);
}
示例5: CallProductOverridedEqualsCheckCurrentEqual
public void CallProductOverridedEqualsCheckCurrentEqual()
{
Product p1 = new Product("Trek 3500", 500M, 25);
Product p2 = new Product("Trek 3500", 500M, 25);
bool resultEquals = p1.Equals((object)p2);
Assert.AreEqual<bool>(true, resultEquals);
}
示例6: WhenSameTransientShouldBeTrue
public void WhenSameTransientShouldBeTrue()
{
var product = new Product();
product.Equals(product).Should().Be.True();
}
示例7: WhenComparingSameInstanceOfPersistedEntityThenShouldBeTrue
public void WhenComparingSameInstanceOfPersistedEntityThenShouldBeTrue()
{
var product = new Product {Id = 123};
product.Equals(product)
.Should().Be.True();
}