Example #1
0
        public void TestPrepareRequest()
        {
            const string apiKey = "apiKey";

            ClientManager.SetCurrent(apiKey);
            Request request = new Request("resource");

            List <String> parameters = ClientManager.Build().PrepareRequest(request).Parameters.Select(parameter => parameter.ToString()).ToList();

#if NET35
            string user_agent = string.Concat("EasyPost/v2 CSharp (.NET 3.5)/", ClientManager.Build().version);
#elif NET40
            string user_agent = string.Concat("EasyPost/v2 CSharp (.NET 4.0)/", ClientManager.Build().version);
#elif NETCORE31
            string user_agent = string.Concat("EasyPost/v2 CSharp (.NET Core 3.1)/", ClientManager.Build().version);
#else
            string user_agent = string.Concat("EasyPost/v2 CSharp (.NET 4.5.2)/", ClientManager.Build().version);
#endif

#if DEBUG
            user_agent += " [DEBUG]";
#endif

            CollectionAssert.Contains(parameters, "user_agent=" + user_agent);
            CollectionAssert.Contains(parameters, "authorization=Bearer " + apiKey);
            CollectionAssert.Contains(parameters, "content_type=application/json");
        }
Example #2
0
        public void TestFactoryDelegate()
        {
            ClientManager.SetCurrent(() => new Client(new ClientConfiguration("apiKey")));
            Client client = ClientManager.Build();

            Assert.AreEqual("apiKey", client.configuration.ApiKey);
        }
Example #3
0
        public void TestApiKey()
        {
            ClientManager.SetCurrent("apiKey");
            Client client = ClientManager.Build();

            Assert.AreEqual("apiKey", client.configuration.ApiKey);
        }
Example #4
0
        public void TestFactoryDelegateForUniqueObjects()
        {
            ClientManager.SetCurrent(() => new Client(new ClientConfiguration("apiKey")));
            Client client1 = ClientManager.Build();
            Client client2 = ClientManager.Build();

            Assert.AreNotSame(client1, client2);
        }
Example #5
0
        public void TestApiKeyForUniqueObjects()
        {
            ClientManager.SetCurrent("apiKey");
            Client client1 = ClientManager.Build();
            Client client2 = ClientManager.Build();

            Assert.AreNotSame(client1, client2);
        }
Example #6
0
        public static async Task <ItemFactoryBuilder> CreateAsync(bool refreshCitadelData)
        {
            await ClientManager.Build();

            var marketApi      = new MarketApi();
            var citadelManager = await CitadelObtainer.BuildAsync(marketApi, refreshCitadelData);

            var itemManager = new GeneralItemManager();

            return(new ItemFactoryBuilder(citadelManager, new BlueprintService(new BlueprintManager(), itemManager), itemManager.GetItemName, itemManager.GetItemId, new MaterialsService()));
        }
Example #7
0
        public void TestPrepareRequest()
        {
            const string apiKey = "apiKey";

            ClientManager.SetCurrent(apiKey);
            Request request = new Request("resource");

            List <String> parameters = ClientManager.Build().PrepareRequest(request).Parameters.Select(parameter => parameter.ToString()).ToList();

            CollectionAssert.Contains(parameters, "user_agent=EasyPost/v2 CSharp/" + ClientManager.Build().version);
            CollectionAssert.Contains(parameters, "authorization=Bearer " + apiKey);
            CollectionAssert.Contains(parameters, "content_type=application/json");
        }
Example #8
0
 public void TestNotConfigured()
 {
     ClientManager.Build();
 }