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 );
		}
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
		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;
		}
Exemplo n.º 5
0
		public Order Order_ForCustomer( Customer customer )
		{
			Order order = Order();
			order.Customer = customer;
			return order;
		}
Exemplo n.º 6
0
		public Customer Customer()
		{
			var customer = new Customer
			               	{
			               			Id = GetUniqueId(),
			               			FirstName = ARandom.FirstName(),
			               			LastName = ARandom.LastName()
			               	};
			return customer;
		}
Exemplo n.º 7
0
		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();
		}
Exemplo n.º 8
0
 public CreateCustomerStep2(Customer customer)
     : this()
 {
     this.customer = customer;
 }