本文整理汇总了C#中Customer.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.Equals方法的具体用法?C# Customer.Equals怎么用?C# Customer.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
List<Payment> payments = new List<Payment>
{
new Payment("Payyy", "10 lv."),
new Payment("Payyy2", "210 lv."),
};
//check 2 payments with Equals and ==
//Payment p1 = new Payment("Payyy", "10 lv.");
//Payment p2 = new Payment("Payyy", "10 lv.");
//Console.WriteLine(p1.Equals(p2));
//Console.WriteLine(p1 == p2);
//Console.WriteLine("=================================");
//Check 2 customer, one a clone of the other, with Equals and ==
Customer a = new Customer("Pesho", "Ivanov", "Petrov", 1111, "Severna Koreq", "08898967674", "[email protected]", payments, CustomerType.Golden);
//Customer b = new Customer("Pesho", "Ivanov", "Petrov", 1111, "Severna Koreq", "08898967674", "[email protected]", payments, CustomerType.Golden);
Customer b = a.Clone() as Customer;
Customer c = a;
Console.WriteLine(a.Equals(b)); //da
Console.WriteLine(a.Equals(c)); //da
Console.WriteLine(a == b); //ne
c.FirstName = "blq";
Console.WriteLine(a == c); //da
//CompareTo
a.FirstName = "Pesho";
Console.WriteLine(a.CompareTo((Customer)b)); //0
b.FirstName = "Todor";
Console.WriteLine(a.CompareTo((Customer)b)); //Pesho > Todor
}
示例2: Main
public static void Main()
{
Customer rado = new Customer("Rado", "Radov", "Radov", 9043367759, "Radovo", "0888696969", "[email protected]", CustomerType.Golden, new List<Payment>());
Customer radoCloned = (Customer) rado.Clone();
Console.WriteLine(rado.Equals(radoCloned)); // Should be true
radoCloned.Id = 4356345563;
radoCloned.Payments.Add(new Payment("ProductName", 43543643));
Console.WriteLine(rado.Equals(radoCloned)); // Should be false
Console.WriteLine(rado.CompareTo(radoCloned) > 0); // The name is the same but the ID of rado > of ID radoCloned
}
示例3: TestEquals
public void TestEquals()
{
var customer = new Customer();
var customer2 = customer;
var clone = customer.Clone();
Assert.IsTrue(customer.Equals(customer2));
Assert.IsTrue(customer2.Equals(customer));
Assert.IsFalse(customer.Equals(new Customer()));
Assert.IsFalse(new Customer().Equals(customer));
Assert.IsTrue(customer.Equals(clone));
Assert.IsTrue(clone.Equals(customer));
}
示例4: TestEntityEquals_IdEquals
public void TestEntityEquals_IdEquals() {
_customer = new Customer( 1 );
_customer2 = new Customer( 1 );
Assert.IsTrue( _customer.Equals( _customer2 ) );
Assert.IsTrue( _customer == _customer2 );
Assert.IsFalse( _customer != _customer2 );
}
示例5: Customers_Are_Different
public void Customers_Are_Different()
{
var customerA = new Customer
{
Id = 0,
FirstName = "Adelia",
LastName = "Kessler",
Address = new Address
{
Street = "16256 Reichel Plains",
City = "Ryanbury",
State = "VA",
Zip = "58851"
}
};
var customerB = new Customer
{
Id = 1,
FirstName = "Melissa",
LastName = "Labadie",
Address = new Address
{
Street = "4751 Johan Landing",
City = "East Bettye",
State = "SD",
Zip = "54538"
}
};
Assert.IsFalse(customerA.Equals(customerB));
}
示例6: Main
static void Main(string[] args)
{
List<Payment> payments = new List<Payment>()
{
new Payment("Laptop", 999),
new Payment("Glasses", 300),
new Payment("Vodka", 60)
};
Customer pesho = new Customer("Pesho", "Peshev", "Peshov", "6840562897",
"Karlukovo", "+3598888888888", "[email protected]", payments, CustomerType.Golden);
Customer gosho = new Customer("Gosho", "Georgiev", "Goshev", "5068795469",
"Gorna Orqhovica", "+359878967458", "[email protected]", payments, CustomerType.Diamond);
Console.WriteLine(pesho.CompareTo(gosho));
Console.WriteLine(pesho.Equals(gosho));
Console.WriteLine();
Console.WriteLine(pesho);
Console.WriteLine(pesho.GetHashCode());
object clonedCustomer = gosho.Clone();
Console.WriteLine(clonedCustomer.Equals(gosho));
}
示例7: Customers_Are_Same
public void Customers_Are_Same()
{
var customerA = new Customer
{
Id = 0,
FirstName = "Adelia",
LastName = "Kessler",
Address = new Address
{
Street = "16256 Reichel Plains",
City = "Ryanbury",
State = "VA",
Zip = "58851"
}
};
var customerB = new Customer
{
Id = 0,
FirstName = "Adelia",
LastName = "Kessler",
Address = new Address
{
Street = "16256 Reichel Plains",
City = "Ryanbury",
State = "VA",
Zip = "58851"
}
};
Assert.IsTrue(customerA.Equals(customerB));
}
示例8: SameCustomerLoadedTwiceFromDBIsTheSame
public void SameCustomerLoadedTwiceFromDBIsTheSame()
{
var someCustomerId = Guid.NewGuid();
var cust1 = new Customer (someCustomerId, validFirstName);
var cust2 = new Customer (someCustomerId, validFirstName);
Assert.IsTrue (cust1.Equals(cust2));
}
示例9: CanCreateOrder
public void CanCreateOrder()
{
Customer customer = new Customer("ACME");
Order order = new Order(customer);
Assert.IsTrue(customer.Equals(order.OrderedBy));
}
示例10: ModifyOwningCustomer
public void ModifyOwningCustomer(Customer owningCustomer)
{
Customer currentOwningCustomer = OwningCustomer;
if (owningCustomer == null || owningCustomer.Equals(currentOwningCustomer))
return;
owningCustomer.AddToCars(this);
onModifyOwningCustomer(currentOwningCustomer, owningCustomer);
}
示例11: AddCustomerTest
public void AddCustomerTest()
{
PaymentController control = PaymentController.GetInstance();
PersistenceManager.GetInstance().DeleteAll();
Customer cust = new Customer {
FirstName = ("FirstName1"),
MiddleName = ("MiddleName1"),
LastName = ("LastName1"),
Number = ("1")
};
Assert.IsTrue(control.AddCustomer(cust));
Customer cust1 = new Customer {
FirstName = ("FirstName2"),
MiddleName = ("MiddleName2"),
LastName = ("LastName2"),
Number = ("2")
};
Assert.IsTrue(control.AddCustomer(cust1));
Customer custReal = control.GetCustomer(cust.ID);
Assert.IsTrue(cust.Equals(custReal));
Customer cust1Real = control.GetCustomer(cust1.ID);
Assert.IsTrue(cust1.Equals(cust1Real));
Assert.IsFalse(control.AddCustomer(cust));
Assert.IsNull(control.GetCustomer(Guid.NewGuid()));
Customer cust3 = new Customer {
FirstName = ("FirstName3"),
MiddleName = ("MiddleName3"),
LastName = ("LastName3"),
Number = ("3")
};
Assert.IsTrue(control.AddCustomer(cust3));
Assert.IsTrue(control.RemoveCustomer(cust.ID));
Assert.IsNull(control.GetCustomer(cust.ID));
Assert.IsFalse(control.RemoveCustomer(cust.ID));
Customer cust4 = new Customer {
FirstName = ("FirstName4"),
MiddleName = ("MiddleName4"),
LastName = ("LastName4"),
Number = ("3")
};
Assert.IsFalse ( control.AddCustomer ( cust4 ) );
Assert.IsNull(control.GetCustomer(cust4.ID));
}
示例12: Main
static void Main()
{
Customer lili = new Customer(
"Lili",
"Kalapova",
"Bonin",
1234567,
"Plovdiv",
"4567456",
"[email protected]",
new List<Payment>() { new Payment("Lenovo laptop", 850) },
CustomerType.OneTime);
Customer gosho = new Customer(
"Gosho",
"Kostadinov",
"Kalapov",
9876543,
"Luisville",
"09017654",
"[email protected]",
new List<Payment>() { new Payment("Calculator", 50), new Payment("Mouse Pad", 13), new Payment("Mic", 6) },
CustomerType.Regular);
Customer emo = new Customer(
"Emil",
"Georgiev",
"Georgiev",
5454590,
"Sofia",
"08983334",
"[email protected]",
new List<Payment>() { new Payment("Server", 2850) },
CustomerType.Golden);
var liliCopy = lili;
lili.Payments.Add(new Payment("mouse", 12));
lili.LastName = "kalapova-bonin";
Console.WriteLine(lili);
Console.WriteLine(liliCopy);
Console.WriteLine(liliCopy == lili);
Console.WriteLine(lili.Equals(liliCopy));
var liliClone = (Customer)lili.Clone();
Console.WriteLine(lili == gosho);
Console.WriteLine(lili == liliClone);
Console.WriteLine(lili == liliCopy);
Console.WriteLine(lili.CompareTo(gosho));
Console.WriteLine(emo.CompareTo(lili));
Console.WriteLine(lili.CompareTo(liliClone));
}
示例13: TestClone
public void TestClone()
{
var customer = new Customer();
var clone = customer.Clone();
Assert.IsFalse(customer == clone);
Assert.AreNotSame(customer, clone);
Assert.AreEqual(customer, clone);
Assert.IsTrue(customer.Equals(clone));
Assert.AreEqual(customer.GetHashCode(), clone.GetHashCode());
Assert.IsInstanceOf<Customer>(clone);
Assert.AreEqual(customer.Id, ((IPersistentObject)clone).Id);
}
示例14: Have
public static bool Have(Customer customer)
{
bool flag = false;
Parallel.ForEach(CustomerQuery.Get(),cust=>
{
if (customer.Equals(cust))
{
flag = true;
return;
}
});
return flag;
}
示例15: CustomerTest
public void CustomerTest()
{
PersistenceManager pm = PersistenceManager.GetInstance();
pm.DeleteAll();
Customer cust = new Customer{
FirstName = ( "FirstName1" ),
MiddleName = ( "MiddleName1" ),
LastName = ( "LastName1" ),
Number = ( "1" )
};
Assert.IsTrue ( pm.AddCustomer ( cust ) );
Assert.IsTrue ( pm.IsExistCustomerWithNumber ( "1" ) );
Customer cust1 = new Customer{
FirstName = ( "FirstName2" ),
MiddleName = ( "MiddleName2" ),
LastName = ( "LastName2" ),
Number = ( "2" )
};
Assert.IsTrue ( pm.AddCustomer(cust1) );
Assert.IsTrue ( pm.IsExistCustomerWithNumber ( "2" ) );
Customer custReal = pm.GetCustomer ( cust.ID );
Assert.IsTrue ( cust.Equals ( custReal ) );
Customer cust1Real = pm.GetCustomer(cust1.ID);
Assert.IsTrue(cust1.Equals(cust1Real));
Assert.IsFalse ( pm.AddCustomer ( cust ) );
Assert.IsNull ( pm.GetCustomer ( Guid.NewGuid() ) );
Customer cust3 = new Customer {
FirstName = ("FirstName3"),
MiddleName = ("MiddleName3"),
LastName = ("LastName3"),
Number = ("3")
};
Assert.IsTrue(pm.AddCustomer(cust3));
Assert.IsTrue ( pm.IsExistCustomerWithNumber ( "3" ) );
Assert.IsFalse ( pm.IsExistCustomerWithNumber ( "4" ) );
Assert.IsFalse ( pm.IsExistCustomerWithNumber ( "vjkdhsfjk" ) );
Assert.IsTrue ( pm.RemoveCustomer ( cust.ID ) );
Assert.IsNull ( pm.GetCustomer ( cust.ID ) );
Assert.IsFalse ( pm.RemoveCustomer ( cust.ID ) );
}