public void add_payment_success()
    {
        //Arrange
        var cardTypeId     = 1;
        var alias          = "fakeAlias";
        var cardNumber     = "124";
        var securityNumber = "1234";
        var cardHolderName = "FakeHolderNAme";
        var expiration     = DateTime.Now.AddYears(1);
        var identity       = new Guid().ToString();
        var fakeBuyerItem  = new Buyer(identity);

        //Act
        var result = fakeBuyerItem.AddPaymentMethod(cardTypeId, alias, cardNumber, securityNumber, cardHolderName, expiration);

        //Assert
        Assert.NotNull(result);
    }
        public async Task <string> Handle(CreateOrderCommand createOrderCommand)
        {
            using (var scope = _scopeFactory.CreateScope())
            {
                try
                {
                    // Create scope to deal with 'scoped' lifetime of the DbContext object.
                    // Here, we're on a separate thread from the main thread and DbContext
                    // reference from main has been disposed.
                    //https://github.com/mjrousos/MultiThreadedEFCoreSam

                    // Get references to read repository
                    var readModelOrderRepository = scope.ServiceProvider.GetRequiredService <IOrderRepository>();

                    // Create Order domain aggregate
                    var order = new Order(
                        createOrderCommand.UserName,
                        createOrderCommand.CheckoutId,
                        createOrderCommand.Total,
                        createOrderCommand.CorrelationToken
                        );

                    // Set correlationToken
                    _correlationToken = createOrderCommand.CorrelationToken;

                    //_orderId = order.orderid;

                    // Project line items into OrderDetail method exposed in the root Order aggregate.
                    // This practice respects that Order is the root in the Order aggregate.
                    foreach (var item in createOrderCommand.OrderDetails)
                    {
                        order.AddOrderItem(item.Title, item.AlbumId, item.Artist, item.Quantity, item.UnitPrice);
                    }

                    // Create Buyer domain aggregate
                    var buyer = new Buyer(
                        createOrderCommand.UserName,
                        createOrderCommand.FirstName,
                        createOrderCommand.LastName,
                        createOrderCommand.Address,
                        createOrderCommand.City,
                        createOrderCommand.State,
                        createOrderCommand.PostalCode,
                        createOrderCommand.Phone,
                        createOrderCommand.Email);

                    // Add payment method for Buyer
                    buyer.AddPaymentMethod(createOrderCommand.CreditCardNumber,
                                           createOrderCommand.SecurityCode,
                                           createOrderCommand.CardholderName,
                                           createOrderCommand.ExpirationDate);

                    // Add Buyer information to the Order Aggregate so that we can do
                    // use EF's 'fixup" to perform a single insert into the dataStore
                    // for the entire graph.
                    order.Buyer = buyer;

                    // Add Order to ReadDataStore
                    await readModelOrderRepository.Add(order, _telemetryClient);

                    _logger.LogInformation($"Created new order for Request {order.CorrelationToken} ");
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Error creating Order: {ex.Message} for Request {_correlationToken} ");
                    throw;
                }

                return(_orderId);
            }
        }