protected override void TestSetUp() { _expectedCustomer = a.Customer.build(); _db.Add( _expectedCustomer ) .Persist(); _actualCustomer = _session.Load< Customer >( _expectedCustomer.Id ); }
public void OrderTotalShouldBeTheSumOfTheLineItems() { // Arrange. var customer = new Customer { FirstName = "Bob", LastName = "Smith" }; var order = new Order { Customer = customer, OrderDate = DateTime.Now }; var lineItem1 = new LineItem { Order = order, Product = new Product { Name = "Product1", Description = "Product1 Description" }, Quantity = 1, UnitPrice = 1.60 }; var lineItem2 = new LineItem { Order = order, Product = new Product { Name = "Product2", Description = "Product2 Description" }, Quantity = 10, UnitPrice = 25.99 }; order.LineItems.Add( lineItem1 ); order.LineItems.Add( lineItem2 ); // Act. var actualTotal = order.TotalAmount; // Assert. const double expectedTotal = ( 1 * 1.60 ) + ( 10 * 25.99 ); actualTotal.Should().Be.EqualTo( expectedTotal ); }
private void NextButtonClicked(object sender, EventArgs e) { messageLabel.Text = string.Empty; int age; if (string.IsNullOrEmpty(nameTextBox.Text)) { messageLabel.Text = "/Name cannot be empty"; } if (!int.TryParse(ageTextBox.Text, out age)) { messageLabel.Text += "/Age should be a valid number"; } if (!string.IsNullOrEmpty(messageLabel.Text)) return; Customer customer = new Customer(); customer.Name = nameTextBox.Text; customer.Age = int.Parse(ageTextBox.Text); Close(); CreateCustomerStep2 step2 = new CreateCustomerStep2(customer); step2.StartPosition = FormStartPosition.CenterParent; step2.Show(); }
public TestDatabase Add( Customer customer ) { // Exit if null or if this has already been added. if ( _customers.AddIfUnique( customer, x => x.Id == customer.Id ) ) { // Add parents. // Add children. } return this; }
public Order Order_ForCustomer( Customer customer ) { Order order = Order(); order.Customer = customer; return order; }
public Customer Customer() { var customer = new Customer { Id = GetUniqueId(), FirstName = ARandom.FirstName(), LastName = ARandom.LastName() }; return customer; }
public void Insert( Customer customer ) { IDbCommand command = _session.CreateCommandWithinCurrentTransaction(); command.CommandText = SqlGenerator.GenerateInsertSql( "Customer", new[] { "Id", "FirstName", "LastName" }, // HasIdentityColumn ); HasNoIdentityColumn ); command.SetParameter( "@Id", customer.Id ); command.SetParameter( "@FirstName", customer.FirstName ); command.SetParameter( "@LastName", customer.LastName ); LogCommand( command ); command.ExecuteNonQuery(); }
public CreateCustomerStep2(Customer customer) : this() { this.customer = customer; }