Exemple #1
0
        public void SalesReceiptEmailToEmailAddressInBillEmailTest()
        {
            try
            {
                List <SalesReceipt> salesReceipts = Helper.FindAll <SalesReceipt>(dataServiceTestCases.GetContext(), new SalesReceipt(), 1, 10);

                Assert.IsTrue(salesReceipts.Count > 0);

                salesReceipts[0].BillEmail = new EmailAddress {
                    Address = "*****@*****.**"
                };

                SalesReceipt updatedSalesReceipt = Helper.Update <SalesReceipt>(dataServiceTestCases.GetContext(), salesReceipts[0]);


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


                SalesTransaction returnedEntity = service.SendEmail <SalesReceipt>(updatedSalesReceipt);
            }
            catch (IdsException idsEx)
            {
                Assert.IsTrue(idsEx.Message == "Email address is either not in valid format or is not provided");
            }
        }
        public void SalesReceiptEmailToggleSerializationTest()
        {
            try
            {
                if (dataServiceTestCases.GetContext().IppConfiguration.Message.Request.SerializationFormat == SerializationFormat.Xml)
                    dataServiceTestCases.GetContext().IppConfiguration.Message.Request.SerializationFormat = SerializationFormat.Json;

                if (dataServiceTestCases.GetContext().IppConfiguration.Message.Response.SerializationFormat == SerializationFormat.Xml)
                    dataServiceTestCases.GetContext().IppConfiguration.Message.Response.SerializationFormat = SerializationFormat.Json;
                
                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());

                SalesTransaction returnedEntity = service.SendEmail<SalesReceipt>(salesReceipts[0], "*****@*****.**");

                Assert.IsTrue(returnedEntity.EmailStatus == EmailStatusEnum.EmailSent);
            }
            catch (IdsException idsEx)
            {
                Assert.Fail(idsEx.Message);
            }
            
            
        }
Exemple #3
0
        public void SalesReceiptEmailToEmptyEmailAddressInBillEmailTest()
        {
            try
            {
                List <SalesReceipt> salesReceipts = Helper.FindAll <SalesReceipt>(dataServiceTestCases.GetContext(), new SalesReceipt(), 1, 10);

                Assert.IsTrue(salesReceipts.Count > 0);

                salesReceipts[0].BillEmail = new EmailAddress {
                    Address = ""
                };

                SalesReceipt updatedSalesReceipt = Helper.Update <SalesReceipt>(dataServiceTestCases.GetContext(), salesReceipts[0]);


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


                SalesTransaction returnedEntity = service.SendEmail <SalesReceipt>(updatedSalesReceipt);
            }
            catch (IdsException idsEx)
            {
                Assert.IsNotNull(idsEx);
            }
        }
 public void SalesReceiptEmailNullEntityTest()
 {
     try
     {
         Ipp.DataService.DataService service = new Ipp.DataService.DataService(dataServiceTestCases.GetContext());
         SalesTransaction returnedEntity = service.SendEmail<SalesReceipt>(null, "*****@*****.**");
     }
     catch (IdsException idsEx)
     {
         Assert.IsTrue(idsEx.Message == "Parameter cannot be null.");
     }
 }
        public void SalesReceiptEmailToSpecifiedEmailAddressTest()
        {
            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());

            SalesTransaction returnedEntity = service.SendEmail<SalesReceipt>(salesReceipts[0], "*****@*****.**");

            Assert.IsTrue(returnedEntity.EmailStatus == EmailStatusEnum.EmailSent);
        }
Exemple #6
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);
            }
        }
Exemple #7
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);
            }
        }
Exemple #8
0
        public void SalesReceiptEmailEntityWithNullIdTest()
        {
            try
            {
                List <SalesReceipt> salesReceipts = Helper.FindAll <SalesReceipt>(dataServiceTestCases.GetContext(), new SalesReceipt(), 1, 10);
                Assert.IsTrue(salesReceipts.Count > 0);
                SalesReceipt updatedSalesReceipt = Helper.Update <SalesReceipt>(dataServiceTestCases.GetContext(), salesReceipts[0]);

                updatedSalesReceipt.Id = null;

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


                SalesTransaction returnedEntity = service.SendEmail <SalesReceipt>(updatedSalesReceipt);
            }
            catch (IdsException idsEx)
            {
                Assert.IsTrue(idsEx.Message == "Id of the entity cannot be null or empty.");
            }
        }
Exemple #9
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);
            }
        }