Example #1
0
		private static void ResetLastRunData()
		{
			_LastChange = DateTime.MinValue;
			_Prior = new Analysis();
			//_PriorFailed = String.Empty;
			//_Attempts = 0;
		}
Example #2
0
		public void StateOfEnlightenment_CompletedEqualsTotal_Enlightend()
		{
			Analysis a = new Analysis();
			a.CompletedKoans = 5;
			a.TotalKoans = 5;

			Assert.Equal("You have reached enlightenment.", Master.StateOfEnlightenment(a));
		}
Example #3
0
		public void Encouragement_CompletedEqualsTotal_EmptyString()
		{
			Analysis a = new Analysis();
			a.CompletedKoans = 5;
			a.TotalKoans = 5;

			Assert.Equal(String.Empty, Master.Encouragement(a));
		}
Example #4
0
		public void StateOfEnlightenment_EmptyAnalysis_NotEnlightend()
		{
			var a = new Analysis();
			a.CompletedKoans = 0;
			a.TotalKoans = 5;

			Assert.Equal("You have not yet reached enlightenment.", Master.StateOfEnlightenment(a));
		}
Example #5
0
		public void Encouragement_CompletedNotEqualsTotalAttemptsZero_ProgressingCount()
		{
			Analysis a = new Analysis();
			a.CompletedKoans = 1;
			a.TotalKoans = 5;
			a.FailedAttempts = 0;

			Assert.Equal("You are progressing. Excellent. 1 completed.", Master.Encouragement(a));
		}
Example #6
0
		public void Encouragement_CompletedNotEqualsTotalAttemptsThree_SeekHelp()
		{
			Analysis a = new Analysis();
			a.CompletedKoans = 1;
			a.TotalKoans = 5;
			a.FailedAttempts = 3;

			Assert.Equal("I sense frustration. Do not be afraid to ask for help.", Master.Encouragement(a));
		}
Example #7
0
		public void Encouragement_CompletedNotEqualsTotalAttemptsOne_DontGiveUp()
		{
			Analysis a = new Analysis();
			a.CompletedKoans = 1;
			a.TotalKoans = 5;
			a.FailedAttempts = 1;

			Assert.Equal("Do not lose hope.", Master.Encouragement(a));
		}
Example #8
0
 private static void EchoResult(string output, string projectName)
 {
     string[] lines = output.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
     Master master = new Master(projectName);
     _Prior = master.Analyze(lines, _Prior);
     PrintLastActions(_Prior);
     PrintMastersComments(_Prior);
     PrintAnswersYouSeek(lines, _Prior);
     PrintFinalWords(_Prior);
 }
Example #9
0
		public Analysis Analyze(string[] lines, Analysis prior)
		{
            var result = new Analysis();
			result.LastPassedKoan = FindKoan(lines, _projectName, kExpanded);
			result.FailedKoan = FindKoan(lines, _projectName, kDamaged);
			result.CompletedKoans = CountCompleted(lines);
			result.FailedAttempts = ComputeAttempts(result.FailedKoan, prior);
			int total;
			result.ProgressBar = ComputeProgress(lines, out total);
			result.TotalKoans = total;
			return result;
        }
Example #10
0
		public static string Encouragement(Analysis a)
		{
			if ((a.CompletedKoans == 0 && a.FailedAttempts == 0) || a.CompletedKoans == a.TotalKoans)
			{
				return String.Empty;
			}
			if (a.CompletedKoans > 0 && a.FailedAttempts == 0)
			{
				return string.Format("You are progressing. Excellent. {0} completed.", a.CompletedKoans);
			}
			if (a.FailedAttempts < 3)
			{
				return "Do not lose hope.";
			}
			return "I sense frustration. Do not be afraid to ask for help.";
		}
Example #11
0
 public static string StateOfEnlightenment(Analysis a)
 {
     return(a.CompletedKoans == a.TotalKoans ? "You have reached enlightenment." : "You have not yet reached enlightenment.");
 }
Example #12
0
		private static void PrintFinalWords(Analysis analysis)
		{
			Console.WriteLine();
			Console.WriteLine("sleep is the best meditation");
			Console.WriteLine("your path thus far [{0}] {1}/{2}", analysis.ProgressBar, analysis.CompletedKoans, analysis.TotalKoans);
		}
Example #13
0
		private static void PrintAnswersYouSeek(string[] lines, Analysis analysis)
		{
			if (string.IsNullOrEmpty(analysis.FailedKoan)== false)
			{
				Console.WriteLine();
				Console.WriteLine("The answers you seek...");
				Console.ForegroundColor = ConsoleColor.Red;
				Array.ForEach(Master.WhereToSeek(lines), l => Console.WriteLine("\t{0}", l));
				Console.ForegroundColor = ConsoleColor.White;

				Console.WriteLine();
				Console.WriteLine("Please meditate on the following code:");
				Console.ForegroundColor = ConsoleColor.Red;
				Console.WriteLine("\t{0}", Master.WhatToMeditateOn(lines));
				Console.ForegroundColor = ConsoleColor.White;
			}
		}
Example #14
0
		private static void PrintMastersComments(Analysis analysis)
		{
			Console.WriteLine();
			Console.WriteLine("The Master says:");
			Console.ForegroundColor = ConsoleColor.Cyan;
			Console.WriteLine("\t{0}", Master.StateOfEnlightenment(analysis));
			string encouragement = Master.Encouragement(analysis);
			if (string.IsNullOrEmpty(encouragement) == false)
				Console.WriteLine("\t{0}", encouragement);
			Console.ForegroundColor = ConsoleColor.White;
		}
Example #15
0
		private static void PrintLastActions(Analysis analysis)
		{
			if (string.IsNullOrEmpty(analysis.LastPassedKoan) == false)
			{
				PrintTestLineJustTest(analysis.LastPassedKoan, ConsoleColor.Green, Master.kExpanded);
			}
			if (string.IsNullOrEmpty(analysis.FailedKoan) == false)
			{
				PrintTestLineJustTest(analysis.FailedKoan, ConsoleColor.Red, Master.kDamaged);
			}
		}
Example #16
0
 private static void ResetLastRunData()
 {
     _lastChange = DateTime.MinValue;
     _prior = new Analysis();
 }
Example #17
0
 private static int ComputeAttempts(string failedKoan, Analysis prior)
 {
     return(failedKoan == prior.FailedKoan ? prior.FailedAttempts + 1 : 0);
 }
Example #18
0
		public void Encouragement_NoProgress_EmptyString()
		{
			Analysis a = new Analysis();

			Assert.Equal(String.Empty, Master.Encouragement(a));
		}
Example #19
0
		public static string StateOfEnlightenment(Analysis a)
		{
			return a.CompletedKoans == a.TotalKoans ? "You have reached enlightenment." : "You have not yet reached enlightenment.";
		}
Example #20
0
		private static int ComputeAttempts(string failedKoan, Analysis prior)
		{
			return failedKoan == prior.FailedKoan ? prior.FailedAttempts + 1 : 0;
		}