public static ICustomerAddress MindflyAddressForInserting(Guid customerKey)
        {
            var address = new CustomerAddress(customerKey, "Mindfly")
                {
                    Address1 = "114 W. Magnolia St.",
                    Address2 = "Suite 504",
                    Locality = "Bellingham",
                    Region = "WA",
                    CountryCode = "US",
                    PostalCode = "98225",
                    Phone = "555-555-5555"
                };

            address.ResetDirtyProperties();

            return address;
        }
        public static ICustomerAddress CustomerAddressForInserting(Guid customerKey)
        {
            // this won't work for integration tests because of the database constraint.

            var address = new CustomerAddress(customerKey, "Home")
                {
                    Address1 = "111 Somewhere",
                    AddressTypeFieldKey = new AddressTypeField().Shipping.TypeKey,
                    Company = "Demo Co.",
                    Locality = "Seattle",
                    Region = "WA",
                    PostalCode = "99701",
                    CountryCode = "US"
                };

            address.ResetDirtyProperties();

            return address;
        }
Exemplo n.º 3
0
        public void NewInvoiceReturnsCorrectInvoice()
        {
            //// Arrange
            Guid key = Guid.NewGuid();
            bool wasCalled = false;
            int id = 1;
            Invoice invoice = CreateFakeInvoice(id, key);

            var customer = new AnonymousCustomer(100.00m, 100.00m, DateTime.Now);
                customer.FirstName = "John";
                customer.LastName = "Jones";
                customer.Email = "*****@*****.**";
                customer.MemberId = 1004;

            var address = new CustomerAddress(customer, "Address")
            {
                Address1 = "123 Test St.",
                Address2 = "Apt 1",
                Locality = "USA",
                Region = "USA",
                PostalCode = "97333-0123",
                CountryCode = "US",
                Phone = "555-555-5555",
                Company = "Test Company"
            };
            var invoiceStatus = new InvoiceStatus()
            {
                Alias = "unpaid",
                Name = "Unpaid",
                Active = true,
                Reportable = true,
                SortOrder = 1
            };
            var MockInvoiceService = new Mock<IInvoiceService>();
            MockInvoiceService.Setup(cs => cs.CreateInvoice(customer, address, invoiceStatus, "Test Invoice 1")).Returns(invoice).Callback(() => wasCalled = true);

            MerchelloContext merchelloContext = GetMerchelloContext(MockInvoiceService.Object);

            InvoiceApiController ctrl = new InvoiceApiController(merchelloContext, tempUmbracoContext);

            //// Act
            Invoice result = null;
            //Invoice result = ctrl.NewInvoice(customer, address, invoiceStatus, "Test Invoice 1");

            //// Assert
            Assert.AreEqual(invoice, result);
            Assert.True(wasCalled);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a fake product with fake data for testing
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private Invoice CreateFakeInvoice(int id, Guid key)
        {
            var customer = new AnonymousCustomer(100.00m, 100.00m, DateTime.Now)
            {
                FirstName = "John",
                LastName = "Jones",
                Email = "*****@*****.**",
                MemberId = 1004,
                Key = key,
                Id = 1001
            };
            var address = new CustomerAddress(customer, "Address")
            {
                Address1 = "123 Test St.",
                Address2 = "Apt 1",
                Locality = "USA",
                Region = "USA",
                PostalCode = "97333-0123",
                CountryCode = "US",
                Phone = "555-555-5555",
                Company = "Test Company"
            };

            var invoiceStatus = new InvoiceStatus()
            {
                Alias = "unpaid",
                Name = "Unpaid",
                Active = true,
                Reportable = true,
                SortOrder = 1
            };
            return new Invoice(customer, address, invoiceStatus, 100.00m)
            {
                Id = id
            };
        }
Exemplo n.º 5
0
 /// <summary>
 /// The as customer address.
 /// </summary>
 /// <param name="adr">
 /// The adr.
 /// </param>
 /// <returns>
 /// The <see cref="ICustomerAddress"/>.
 /// </returns>
 public static ICustomerAddress AsCustomerAddress(this CustomerAddressModel adr)
 {
     var customerAddress = new CustomerAddress(adr.CustomerKey)
                {
                    Label = adr.Label,
                    FullName = adr.FullName,
                    Company = adr.Company,
                    AddressType = adr.AddressType == "shipping" ? AddressType.Shipping : AddressType.Billing,
                    Address1 = adr.Address1,
                    Address2 = adr.Address2,
                    Locality = adr.Locality,
                    Region = adr.Region,
                    PostalCode = adr.PostalCode,
                    CountryCode = adr.CountryCode,
                    Phone = adr.Phone,
                    IsDefault = false
                };
     if (!adr.Key.Equals(Guid.Empty)) customerAddress.Key = adr.Key;
     return customerAddress;
 }