public void IsPrimeTest() { var primeNumber = 3; var pmService = new PrimeNumberService(); var result = pmService.IsPrime(primeNumber); Assert.IsTrue(result); }
public void IsPrimeTestWhenNumberIs1or0() { int[] primeNumbers = {0,1,4}; var pmService = new PrimeNumberService(); foreach (var primeNumber in primeNumbers) { var result = pmService.IsPrime(primeNumber); Assert.IsFalse(result); } }
public void FactorizeTest() { var number = 10; int[] returnValue = {1, 10, 2, 5}; var pmService = new PrimeNumberService(); var result = pmService.Factorize(number); Assert.IsTrue(result.Length == 4); Assert.IsTrue(result.Any( x => returnValue.Contains(x))); }
static void Main(string[] args) { IKernel kernel = new StandardKernel(new PrimeNumberModule()); var loggerService = kernel.Get<NLoggerCore>(); var config = new LoggingConfiguration(); var consoleTarget = new ColoredConsoleTarget(); config.AddTarget("console", consoleTarget); var rule = new LoggingRule("*", LogLevel.Trace, consoleTarget); config.LoggingRules.Add(rule); LogManager.Configuration = config; Logger logger = LogManager.GetLogger("test"); //var logger = new Kata.Core.Log.Concrete.Logger(config.GetConfig(), "primelogger"); var primeNumberService = new PrimeNumberService(); int number; logger.Trace("This tool is to get the factors of a number you enter and to return the prime numbers"); logger.Trace(""); logger.Trace("Enter in a number!"); string value = Console.ReadLine(); while (!Int32.TryParse(value, out number)) { logger.Trace("value must be a number."); value = Console.ReadLine(); } var factors = primeNumberService.Factorize(number); foreach (var factor in factors) { logger.Trace("these are the factors and the primes of the factors"); logger.Trace(string.Format("factor: {0} and is this factor a primenumber: {1}", factor, primeNumberService.IsPrime(factor))); } Console.ReadKey(); }