public void GetByKey_Anykey_CallsQueryMethodOfRepository()
        {
            // Setup dependency
              var settingsMock = new Mock<ISettings>();
              var uoMock = new Mock<IUnitOfWork>();
              var repositoryMock = new Mock<IRepository>();
              var serviceLocatorMock = new Mock<IServiceLocator>();
              serviceLocatorMock.Setup(x => x.GetInstance<IRepository>())
              .Returns(repositoryMock.Object);
              ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

              // Arrange
              Guid id = Guid.NewGuid();
              var key = "MARK_UP_ON_PLATFORM";
              SystemConfig system = new SystemConfig()
              {
              Id=id,
              Name = key,
              Value = "1234"
              };
              SystemConfig[] systems = new SystemConfig[] { system };
              repositoryMock.Setup(e => e.Query<SystemConfig>()).Returns(systems.AsQueryable());
              // Act

              var systemConfigService = new SystemConfigService(uoMock.Object, repositoryMock.Object, settingsMock.Object);
              SystemConfigDto actualSystemconfig = systemConfigService.GetByKey(key);
              // Assert
              Assert.AreEqual(id, actualSystemconfig.Id);
        }
        /// <summary>
        /// Create a consultation invoice
        /// </summary>
        /// <param name="minimumCharge">true if apply minimum charge</param>
        /// <returns></returns>
        public InvoiceDto CreateConsultationInvoice(decimal amount, Guid bookingId, bool minimumCharge, bool isCustomer, string transactionId)
        {
            var SystemConfig = new SystemConfigService(UnitOfWork, Repository, Settings);
            string emailAddress = string.Empty;

            Invoice invoice = new Invoice(amount, InvoiceType.Consultation,
                Currency.AUD.ToString(), string.Empty,
                true, null, DateTime.UtcNow, DateTime.UtcNow);

            invoice.InvoiceNumber = GetInvoiceNumber();

            Booking booking = Repository.FindById<Booking>(bookingId);
            invoice.User = isCustomer ? booking.Customer : booking.Specialist;
            emailAddress = invoice.User.Email;

            invoice.Description = string.Format(InvoiceConst.InvoiceNormalDescription, booking.ReferenceNo, invoice.User.ExposedAs<UserDto>().Name);

            Log.Debug("CreateConsultationInvoice - before calculate GST - Customer:" + booking.Customer.UserName
                + " - specialist:" + booking.Specialist.UserName
                + " - Amount: " + amount
                + " - GSTRegistered:" + booking.Specialist.Profile.GstRegistered
                + " - SpecializationGST:" + booking.Specialization.GST);

            invoice.GST = booking.Specialist.Profile.GstRegistered
                ? booking.Specialization.GST
                    ? SubtractGSTCalculator(amount)
                    : 0
                : 0;

            Log.Debug("CreateConsultationInvoice - after calculate GST - Customer:" + booking.Customer.UserName
                + " - specialist:" + booking.Specialist.UserName
                + " - Amount: " + amount + " - Invoice Calculated GST:" + invoice.GST + " - function calculate GST return:" + SubtractGSTCalculator(amount));
            invoice.TransactionId = transactionId;
            if (minimumCharge) // minimum charge invoice
            {
                invoice.Description = string.Format(InvoiceConst.InvoiceCancelDescription, booking.ReferenceNo) + InvoiceConst.InvoiceApplyMinimumDescription;
                invoice.Duration = 0;

                invoice.RatePerMinute = booking.RatePerMinute;
                invoice.ConsultationType = ConsultationType.MinimumCharge;
                invoice.Booking = booking;

                invoice.DeclineBookingRate = isCustomer ? booking.CustomerMinCharge : booking.SpecialistMinCharge;

                invoice.Amount = invoice.DeclineBookingRate;
            }
            else // normal consultation invoice
            {
                var call = Repository.Query<Call>().FirstOrDefault(x => x.Booking.Id.Equals(bookingId));

                if (call == null)
                {
                    throw new ArgumentException("Generate consulation invoice with booking Id: " + bookingId);
                }

                ConsultationType consultType;

                if (call.Booking.Type == BookingType.ASAP)
                {
                    consultType = ConsultationType.StandardHour;
                }
                else
                {
                    Enum.TryParse(call.Booking.Type.ToString(), out consultType);
                }

                invoice.Booking = call.Booking;
                invoice.Duration = call.Duration;

                invoice.RatePerMinute = isCustomer ? call.Booking.CostPerMinute : call.Booking.RatePerMinute;

                invoice.ConsultationType = consultType;
                if (call.Duration < Convert.ToInt32(SystemConfig.GetByKey(ParamatricBusinessRules.STARTING_TIME.ToString()).Value))
                {
                    invoice.Description += InvoiceConst.InvoiceApplyMinimumDescription;
                }
            }

            Repository.Insert<Invoice>(invoice);
            UnitOfWork.Save();
            Log.Debug("CreateConsultationInvoice - after insert invoice - Customer:" + booking.Customer.UserName
                + " - specialist:" + booking.Specialist.UserName
                + " - Amount: " + invoice.Amount
                + " - Invoice Calculated GST:" + invoice.GST);

            if (invoice.Id.Equals(Guid.Empty))
            {
                throw new ArgumentException("Cannot save consultation invoice to database");
            }

            return invoice.ExposedAs<InvoiceDto>();
        }