public void Can_check_whether_customer_is_admin() { var customer = new Customer(); customer.CustomerRoles.Add(new CustomerRole() { Active = true, Name = "Registered", SystemName = SystemCustomerRoleNames.Registered }); customer.CustomerRoles.Add(new CustomerRole() { Active = true, Name = "Guests", SystemName = SystemCustomerRoleNames.Guests }); customer.IsAdmin().ShouldBeFalse(); customer.CustomerRoles.Add( new CustomerRole() { Active = true, Name = "Administrators", SystemName = SystemCustomerRoleNames.Administrators }); customer.IsAdmin().ShouldBeTrue(); }
/// <summary> /// Gets a value indicating whether a customer can cancel recurring payment /// </summary> /// <param name="customerToValidate">Customer</param> /// <param name="recurringPayment">Recurring Payment</param> /// <returns>value indicating whether a customer can cancel recurring payment</returns> public virtual bool CanCancelRecurringPayment(Customer customerToValidate, RecurringPayment recurringPayment) { if (recurringPayment == null) return false; if (customerToValidate == null) return false; var initialOrder = recurringPayment.InitialOrder; if (initialOrder == null) return false; var customer = recurringPayment.InitialOrder.Customer; if (customer == null) return false; if (initialOrder.OrderStatus == OrderStatus.Cancelled) return false; if (!customerToValidate.IsAdmin()) { if (customer.Id != customerToValidate.Id) return false; } if (!recurringPayment.NextPaymentDate.HasValue) return false; return true; }