How to create an OrderGroup in a unit test


I'm trying to unit test some code that accepts an IOrderGroup.  I need to create this construct in order to test this code.  I'm using v10.4 of EpiServer.Commerce.Core. 

Here's what I have currently.  I was following what I found at this link -

private IOrderGroup BuildOrderGroup() {
            var name = "30340";
            var customerId = Guid.NewGuid();
            var orderGroup = new Cart(name, customerId);

            //var fromAddress = new ShoppingCartAddressDto();
            var fromAddress = orderGroup.OrderAddresses.AddNew();
            fromAddress.Line1 = "140 Main ST";
            fromAddress.City = "BROWNSVILLE";
            fromAddress.PostalCode = "38012";
            fromAddress.RegionCode = "TN";

            var toAddress = orderGroup.OrderAddresses.AddNew();
            toAddress.Line1 = "140 Main ST";
            toAddress.City = "BROWNSVILLE";
            toAddress.PostalCode = "38012";
            toAddress.RegionCode = "TN";

            var lineItem = new LineItem {
                Catalog = "101",
                CatalogNode = "c_5637147582",
                Code = "INNER-CIRCLE_1",
                DisplayName = "INNER CIRCLE",
                ExtendedPrice = 49.00m,
                IsGift = false,
                PlacedPrice = 24.50m

            var orderForm = new OrderForm();

            orderGroup.BillingCurrency = "USD";
            return orderGroup;

When I get to the bottom and look at the orderGroup, while I have the correct number of LineItems and OrderAddresses, none of the data I set above can be found.  Those objects are all completely empty with defaults/nulls for all their properties.  Basically, I'm seriously struggling to build this construct and have anything I set be visible in the resulting orderGroup. I do not want to hit the database in any way.  I just need to manually construct an IOrderGroup.

What am I doing wrong?



Edited, Nov 08, 2017 18:34

You are using the MetaObjects which cannot be used for test.  Please refer

Nov 08, 2017 19:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.