Exemplo n.º 1
0
        public static DotMailerCoreClient CreateDotMailerCoreClient()
        {
            NewtonsoftJsonRestSerializer jsonSerializer = new NewtonsoftJsonRestSerializer();
            IEnumerable <string>         contentTypes   = new List <string>()
            {
                "application/json",
                "text/json",
                "text/x-json"
            };

            IOptions <DotMailerCoreOptions> options = Options.Create <DotMailerCoreOptions>(new DotMailerCoreOptions()
            {
                BaseUrl       = "https://api.dotmailer.com/v2/",
                Authenticator = new HttpBasicAuthenticator("*****@*****.**", "demo"),
                Deserializer  = jsonSerializer,
                ContentTypes  = contentTypes
            }
                                                                                            );


            InMemoryCache     inMemoryCache     = new InMemoryCache();
            NullLoggerFactory nullLoggerFactory = new NullLoggerFactory();


            DotMailerCoreClient dotMailerCoreClient = new DotMailerCoreClient(inMemoryCache, jsonSerializer, options, nullLoggerFactory);

            return(dotMailerCoreClient);
        }
Exemplo n.º 2
0
        public static Mock <IRestClient> CreateMockRestClient(IRestResponse restResponse)
        {
            var mockRestClient = new Mock <IRestClient>();
            NewtonsoftJsonRestSerializer jsonSerializer = new NewtonsoftJsonRestSerializer();

            mockRestClient.Setup(client => client.ExecuteTaskAsync(It.IsAny <IRestRequest>())).ReturnsAsync(restResponse as IRestResponse);

            return(mockRestClient);
        }