Exemplo n.º 1
0
        public void GetPdfNullEntityTest()
        {
            try
            {
                List <SalesReceipt> salesReceipts = Helper.FindAll <SalesReceipt>(dataServiceTestCases.GetContext(), new SalesReceipt(), 1, 10);

                Assert.IsTrue(salesReceipts.Count > 0);

                Ipp.DataService.DataService service = new Ipp.DataService.DataService(dataServiceTestCases.GetContext());

                byte[] response = service.GetPdf <SalesReceipt>(null);
            }
            catch (IdsException idsEx)
            {
                Assert.IsNotNull(idsEx);
            }
        }
Exemplo n.º 2
0
        public void GetPdfNonSupportedEntityTest()
        {
            try
            {
                List <Customer> customers = Helper.FindAll <Customer>(dataServiceTestCases.GetContext(), new Customer(), 1, 10);

                Assert.IsTrue(customers.Count > 0);

                Ipp.DataService.DataService service = new Ipp.DataService.DataService(dataServiceTestCases.GetContext());

                byte[] response = service.GetPdf <Customer>(customers[0]);
            }
            catch (IdsException idsEx)
            {
                Assert.IsNotNull(idsEx);
            }
        }
Exemplo n.º 3
0
        [TestMethod][Ignore]//needs physical path access
        public void GetPdfByIdTest()
        {
            List <SalesReceipt> salesReceipts = Helper.FindAll <SalesReceipt>(dataServiceTestCases.GetContext(), new SalesReceipt(), 1, 10);

            Assert.IsTrue(salesReceipts.Count > 0);

            Ipp.DataService.DataService service = new Ipp.DataService.DataService(dataServiceTestCases.GetContext());

            byte[] response = service.GetPdf <SalesReceipt>(salesReceipts[0]);

            //assert to make sure that data is returned
            Assert.IsTrue(response.Length > 0);

            string fileName = string.Format(@"C:\salesreceipt_{0}.pdf", Guid.NewGuid());

            System.IO.File.WriteAllBytes(fileName, response);

            //check if file exists
            Assert.IsTrue(File.Exists(fileName));

            //read the file from bytes and compare bytes
            byte[] readFromFile = File.ReadAllBytes(fileName);


            //bytes read from file should be greater than 0
            Assert.IsTrue(readFromFile.Length > 0);

            for (int i = 0; i < readFromFile.Length; i++)
            {
                Assert.AreEqual(response[i], readFromFile[i]);
            }


            //cleanup
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
        }