Example #1
0
        /// <summary>
        /// Adds the talk.
        /// </summary>
        public static void AddTalk()
        {
            // Get the user interaction data
            UserInterfaceTransactionData uiTransactionData = Program.GetUITransactionData();

            // Ask the conference manager to extract the talk from the user input
            // and schedule the same for the conference
            ConferenceManager.CreateScheduleFor(ref uiTransactionData);

            // Check whether the user input has any faults
            // OR
            // whether the conference manager was unable to create a schedule
            if (uiTransactionData.HasFaults == false)
            {
                // Send out a user friendly message
                Console.WriteLine(Environment.NewLine);
                UIHelper.WriteLine("** The talk has been scheduled successfully!! **", true);
            }
            else
            {
                // Write the error(s) onto the console
                Console.WriteLine(Environment.NewLine);
                foreach (Fault oneError in uiTransactionData.Faults)
                {
                    UIHelper.WriteLine("** There has been some error!! **", true);
                    UIHelper.WriteLine(string.Format(CultureInfo.InvariantCulture, "Message : {0}", oneError.Message), true);
                    UIHelper.WriteLine(string.Format(CultureInfo.InvariantCulture, "Code : {0}", oneError.Code), true);
                }
            }
        }
Example #2
0
             true)] // The length of the talk is valid
        public void Schedule_a_talk(string title, string lengthOfTalk, bool isValidTitle, bool isValidDurationOfTalk)
        {
            UserInterfaceTransactionData userInput = new UserInterfaceTransactionData(title, lengthOfTalk);

            ConferenceManager.CreateScheduleFor(ref userInput);

            if (isValidTitle == false && isValidDurationOfTalk == false)
            {
                userInput.HasFaults.Should().BeTrue();
                userInput.Faults.Count.Should().Be(2);
            }
            else if ((isValidTitle && isValidDurationOfTalk == false) || (isValidTitle == false && isValidDurationOfTalk))
            {
                userInput.HasFaults.Should().BeTrue();
                userInput.Faults.Count.Should().Be(1);
            }
            else if (isValidTitle && isValidDurationOfTalk)
            {
                userInput.HasFaults.Should().BeFalse();
                ConferenceManager.Tracks.Count.Should().BeGreaterThan(0);
            }
        }