public void PrimeFactorsFromNumber1001()
        {
            // arrange
            var number = 1001;
            var calc   = new PrimeCalculator();

            // act
            Action act = () => calc.PrimeFactors(number);

            // assert
            Assert.Throws <ArgumentException>(act);
        }
        public void PrimeFactorsFromNumber40()
        {
            // arrange
            var number   = 40;
            var calc     = new PrimeCalculator();
            var expected = "2*2*2*5";
            // act
            var actual = calc.PrimeFactors(number);

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var stopWatch = new Stopwatch();
            int number    = 900;
            var calc      = new PrimeCalculator();

            stopWatch.Start();
            var resultNumberString = calc.PrimeFactorsString(number);

            stopWatch.Stop();
            WriteLine($"{nameof(calc.PrimeFactorsString)} time stamp is " +
                      stopWatch.Elapsed +
                      " ms");
            stopWatch.Reset();
            stopWatch.Start();
            var resultNumberSB = calc.PrimeFactors(number);

            stopWatch.Stop();
            WriteLine($"{nameof(calc.PrimeFactors)} time stamp is " +
                      stopWatch.Elapsed +
                      " ms");
            WriteLine($"Result string is {resultNumberString}");
            WriteLine($"Result string builder is {resultNumberSB}");
        }