/// <summary>
 /// Get provider credential
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='provider'>
 /// Third party SMS provider
 /// </param>
 /// <param name='id'>
 /// AppId of third party SMS provider
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SmsCredential> GetCredentialAsync(this ISmsOperations operations, string apiVersion, string provider, string id, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetCredentialWithHttpMessagesAsync(apiVersion, provider, id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Get signature
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='signature'>
 /// Name of CEF signature
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Signature> GetSignatureAsync(this ISmsOperations operations, string apiVersion, string account, string signature, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetSignatureWithHttpMessagesAsync(apiVersion, account, signature, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create or Update account
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='update'>
 /// Account
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SmsAccount> CreateOrUpdateAccountAsync(this ISmsOperations operations, string apiVersion, SmsAccount update, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateAccountWithHttpMessagesAsync(apiVersion, update, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Update template
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='template'>
 /// Name of template
 /// </param>
 /// <param name='signature'>
 /// Signature
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Template> UpdateTemplateAsync(this ISmsOperations operations, string apiVersion, string account, string template, TemplateUpdateRequest signature, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateTemplateWithHttpMessagesAsync(apiVersion, account, template, signature, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #5
0
        public void Setup()
        {
            //Create Repo
            _fakeSmsRepo = new Mock <IGenericRepository <Int32, Sms> >();
            //Create unitOfWork and add Repo
            _fakeUnitOfWork = new Mock <IUnitOfWork>();
            _fakeUnitOfWork.Setup(x => x.Repositories).Returns(new Dictionary <string, Object>());
            _fakeUnitOfWork.Object.Repositories.Add(typeof(Sms).Name, _fakeSmsRepo.Object);         //Repositories mapped by entity names in unitOfWork(for detail check UnitOfWork.cs)
            _fakeUnitOfWork.Object.Repositories.Add(typeof(Country).Name, _fakeCountryRepo.Object); //Repositories mapped by entity names in unitOfWork(for detail check UnitOfWork.cs)

            //Will work for first line of SendSms
            List <Country> countries;

            using (var op = new CountryOperations())
            {
                countries = op.GetAll();
                _fakeCountryRepo.Setup(r => r.FindBy(x => x.Cc == toParameter.Substring(1, 2))).Returns(countries.Find(x => x.Cc == toParameter));
            }

            //get real smses from db and add it to repo memory
            //unit tests should not go to database, all logic should be in memory.
            using (var op = new SmsOperations())
            {
                _realGetSentSmsResult = op.GetSentSms(dateFrom, dateTo, skip, take);
                _fakeSmsRepo.Setup(r => r.FilterBy(x => x.DateTime >= dateFrom && x.DateTime <= dateTo).ToList())
                .Returns(op.GetAll().FindAll(x => x.DateTime >= dateFrom && x.DateTime <= dateTo).ToList());
            }

            //put mocked unitOfWork to the operation
            _smsOperations = new SmsOperations(_fakeUnitOfWork.Object);
        }
 /// <summary>
 /// Update template
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='template'>
 /// Name of template
 /// </param>
 /// <param name='signature'>
 /// Signature
 /// </param>
 public static Template UpdateTemplate(this ISmsOperations operations, string apiVersion, string account, string template, TemplateUpdateRequest signature)
 {
     return(operations.UpdateTemplateAsync(apiVersion, account, template, signature).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Delete signature quota
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='signature'>
 /// Name of CEF signature
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteSignatureQuotaAsync(this ISmsOperations operations, string apiVersion, string account, string signature, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.DeleteSignatureQuotaWithHttpMessagesAsync(apiVersion, account, signature, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Delete signature quota
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='signature'>
 /// Name of CEF signature
 /// </param>
 public static void DeleteSignatureQuota(this ISmsOperations operations, string apiVersion, string account, string signature)
 {
     operations.DeleteSignatureQuotaAsync(apiVersion, account, signature).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Create or update signature quota
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='signature'>
 /// Name of CEF signature
 /// </param>
 /// <param name='quota'>
 /// quota count
 /// </param>
 public static void CreateOrUpdateSignatureQuota(this ISmsOperations operations, string apiVersion, string account, string signature, int quota)
 {
     operations.CreateOrUpdateSignatureQuotaAsync(apiVersion, account, signature, quota).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Create or update account credential assignment
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='credentialAssignment'>
 /// Account credential assignment
 /// </param>
 public static IList <SmsCredentialAssignment> CreateOrUpdateCredentialAssignment(this ISmsOperations operations, string apiVersion, string account, SmsCredentialAssignment credentialAssignment)
 {
     return(operations.CreateOrUpdateCredentialAssignmentAsync(apiVersion, account, credentialAssignment).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Delete provider credential
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='provider'>
 /// Third party SMS provider
 /// </param>
 /// <param name='id'>
 /// AppId of third party SMS provider
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteCredentialAsync(this ISmsOperations operations, string apiVersion, string provider, string id, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.DeleteCredentialWithHttpMessagesAsync(apiVersion, provider, id, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Delete provider credential
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='provider'>
 /// Third party SMS provider
 /// </param>
 /// <param name='id'>
 /// AppId of third party SMS provider
 /// </param>
 public static void DeleteCredential(this ISmsOperations operations, string apiVersion, string provider, string id)
 {
     operations.DeleteCredentialAsync(apiVersion, provider, id).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Get provider credential
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='provider'>
 /// Third party SMS provider
 /// </param>
 /// <param name='id'>
 /// AppId of third party SMS provider
 /// </param>
 public static SmsCredential GetCredential(this ISmsOperations operations, string apiVersion, string provider, string id)
 {
     return(operations.GetCredentialAsync(apiVersion, provider, id).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Create or update provider credential
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='credential'>
 /// Credential
 /// </param>
 public static SmsCredential CreateOrUpdateCredential(this ISmsOperations operations, string apiVersion, SmsCredential credential)
 {
     return(operations.CreateOrUpdateCredentialAsync(apiVersion, credential).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Create or update account credential assignment
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='credentialAssignment'>
 /// Account credential assignment
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <SmsCredentialAssignment> > CreateOrUpdateCredentialAssignmentAsync(this ISmsOperations operations, string apiVersion, string account, SmsCredentialAssignment credentialAssignment, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateCredentialAssignmentWithHttpMessagesAsync(apiVersion, account, credentialAssignment, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create or Update account
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='update'>
 /// Account
 /// </param>
 public static SmsAccount CreateOrUpdateAccount(this ISmsOperations operations, string apiVersion, SmsAccount update)
 {
     return(operations.CreateOrUpdateAccountAsync(apiVersion, update).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Get account (SMS)
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 public static SmsAccount GetAccount(this ISmsOperations operations, string apiVersion, string account)
 {
     return(operations.GetAccountAsync(apiVersion, account).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Get signature
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 /// <param name='signature'>
 /// Name of CEF signature
 /// </param>
 public static Signature GetSignature(this ISmsOperations operations, string apiVersion, string account, string signature)
 {
     return(operations.GetSignatureAsync(apiVersion, account, signature).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Get account credential assignments
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='account'>
 /// Name of CEF account
 /// </param>
 public static IList <SmsCredentialAssignment> GetCredentialAssignments(this ISmsOperations operations, string apiVersion, string account)
 {
     return(operations.GetCredentialAssignmentsAsync(apiVersion, account).GetAwaiter().GetResult());
 }