Пример #1
0
        static void Main(string[] args)
        {
            //If the payment is for a physical product, generate a packing slip for shipping.
            //If the payment is for a book, create a duplicate packing slip for the royalty department.
            //If the payment is for a physical product or a book, generate a commission payment to the agent.
            Book book = new Book("Shantaram");                     //New Book

            Console.WriteLine(book.OnPayment().ToString().Trim()); //Payment Received

            Console.WriteLine("------------------------------------------------------------------");

            //If the payment is for the video "Learning to Ski" add a free "First Aid" video to the packing slip
            //(the result of a court decision in 1997).
            //If the payment is for a physical product or a book, generate a commission payment to the agent.
            LearningToSkiVideo video = new LearningToSkiVideo();             //Learning to Ski

            Console.WriteLine(video.OnPayment().ToString().Trim());          //Payment Received

            Console.WriteLine("------------------------------------------------------------------");

            //If the payment is for a membership, activate that membership.
            //If the payment is for a membership or upgrade, e-mail the owner and inform them of the activation/upgrade.
            //If the payment is an upgrade to a membership, apply the upgrade.
            Membership membership = new Membership("*****@*****.**");             //New Membership

            Console.WriteLine(membership.OnActivationPayment().ToString().Trim());      //Payment Received for Activation
            Console.WriteLine(membership.OnUpgradePayment().ToString().Trim());         //Payment Received for Upgradation
        }
Пример #2
0
        public void SkiVideoTest()
        {
            LearningToSkiVideo skiVideo = new LearningToSkiVideo();

            var outPutList = skiVideo.OnPayment().ToString().Split('\n').ToList();

            outPutList = outPutList.Select(o => o.Replace("\n", "").Replace("\r", "")).ToList();
            outPutList = outPutList.Where(o => !String.IsNullOrEmpty(o)).ToList();

            StringBuilder expectedOutPut = new StringBuilder();

            expectedOutPut.AppendLine("Payment Commission Generated for Product: " + skiVideo.ProductDescription);
            expectedOutPut.AppendLine("Packing Slip Generated for Product: " + skiVideo.ProductDescription);

            expectedOutPut.AppendLine("Payment Commission Generated for Product: " + "First Aid");
            expectedOutPut.AppendLine("Packing Slip Generated for Product: " + "First Aid");

            var expectedList = expectedOutPut.ToString().Split('\n').ToList();

            expectedList = expectedList.Select(o => o.Replace("\n", "").Replace("\r", "")).ToList();
            expectedList = expectedList.Where(o => !String.IsNullOrEmpty(o)).ToList();

            bool testResult = (expectedList.All(e => outPutList.Contains(e)) &&
                               outPutList.Count == expectedList.Count);

            Assert.IsTrue(testResult);
        }