public void GetBarcodeGenerateTestThrows()
        {
            // Arrange
            var api     = new BarcodeApi(clientId: "client id", clientSecret: "client secret");
            var request = new GetBarcodeGenerateRequest(
                text: "Very sample text",
                type: EncodeBarcodeType.Code128.ToString(),
                format: "png"
                );

            // Act
            var ex = Assert.Throws <ApiException>(
                () => { api.GetBarcodeGenerate(request); });

            Assert.AreEqual(400, ex.ErrorCode);
            Assert.AreEqual("Bad Request", ex.Message);
        }
Exemplo n.º 2
0
            public byte[] Create()
            {
                if (string.IsNullOrWhiteSpace(_text))
                {
                    return(new byte[0]);
                }

                var barcodeApi = new BarcodeApi(_apiKey, _appSid, "http://api.aspose.cloud/v1.1");

                var apiResponse = barcodeApi.GetBarcodeGenerate(_text, _type, _format, _resolutionX, _resolutionY, _dimensionX, _dimensionY, _enableChecksum);

                if (apiResponse == null)
                {
                    return(new byte[0]);
                }

                return(apiResponse.ResponseStream);
            }
Exemplo n.º 3
0
        public void TestGetBarcodeGenerate()
        {
            BarcodeApi target = new BarcodeApi(APIKEY, APPSID, BASEPATH);

            string text           = "TestGetBarcodeGenerate";
            string type           = "1";
            string format         = "jpeg";
            float? resolutionX    = null;
            float? resolutionY    = null;
            float? dimensionX     = null;
            float? dimensionY     = null;
            string enableChecksum = "";

            ResponseMessage actual;

            actual = target.GetBarcodeGenerate(text, type, format, resolutionX, resolutionY, dimensionX, dimensionY, enableChecksum);

            Assert.AreEqual(200, actual.Code);
            Assert.IsInstanceOfType(new ResponseMessage(), actual.GetType());
        }
        public async Task CanUseExternalToken()
        {
            if (TestConfiguration.AuthType != AuthType.JWT)
            {
                Assert.Ignore($"Unsupported TestConfiguration.AuthType={TestConfiguration.AuthType}");
            }

            var configWithToken = new Configuration
            {
                ApiBaseUrl = TestConfiguration.ApiBaseUrl,
                TokenUrl   = TestConfiguration.TokenUrl,
                JwtToken   = await FetchToken()
            };

            var api = new BarcodeApi(configWithToken);

            using Stream generated = api.GetBarcodeGenerate(
                      new GetBarcodeGenerateRequest(
                          EncodeBarcodeType.QR.ToString(), "Test")
                      );
            Assert.Greater(generated.Length, 0);
        }