Beispiel #1
0
        public void IsTypeOfPrimeNumbersGenerator(int value)
        {
            Assert.IsInstanceOfType(new PrimeNumbersGenerator(), typeof(PrimeNumbersGenerator));
            Assert.IsInstanceOfType(PrimeNumbersGenerator.GetSingleton(), typeof(PrimeNumbersGenerator));
            List <int> lista = new List <int>();

            Assert.IsInstanceOfType(PrimeNumbersGenerator.GetSingleton().GetValuesTo(
                                        out lista, value), typeof(PrimeNumbersGenerator));
            Assert.IsInstanceOfType(new PrimeNumbersGenerator().FindPrimesTo(value), typeof(PrimeNumbersGenerator));
        }
Beispiel #2
0
        public void IsExpectedNumberOfPrimes(int value, int exptected)
        {
            int metodaZwracajacaIloscLiczbPierwszychDoWartosci(int x)
            {
                PrimeNumbersGenerator.GetSingleton().GetValuesTo(out List <int> listOfInts, x);
                return(listOfInts.Count());
            }

            Assert.AreEqual(exptected, metodaZwracajacaIloscLiczbPierwszychDoWartosci(value));
        }
Beispiel #3
0
        public void IsFalseExpectedNumberOfPrimes(int value, int expected)
        {
            CheckIsExpectedNumberOfPrimes metodaZwracajacaIloscLiczbPierwszychDoWartosci = delegate(int x)
            {
                PrimeNumbersGenerator.GetSingleton().GetValuesTo(out List <int> listOfInts, x);
                return(listOfInts.Count());
            };

            Assert.IsFalse(expected.Equals(metodaZwracajacaIloscLiczbPierwszychDoWartosci(value)));
            Assert.AreNotEqual(expected, metodaZwracajacaIloscLiczbPierwszychDoWartosci(value));
        }
        public void DoesSpiralaUlamaHaveRightAmountOfPoints(int generatePrimesToValue, int expectedNumberOfPrimesAndPoints)
        {
            Tuple <List <Tuple <int, int> >, double> tuple =
                new Tuple <List <Tuple <int, int> >, double>(new List <Tuple <int, int> >(), 0);

            PrimeNumbersGenerator.GetSingleton().FindPrimesTo(generatePrimesToValue);
            SpiralaUlamaGenerator spirala = new SpiralaUlamaGenerator().GetValues(100, 100, out tuple);

            Assert.Equals(tuple.Item1.Count, expectedNumberOfPrimesAndPoints);
            Assert.IsTrue(tuple.Item2 > 0);
        }
Beispiel #5
0
        ///
        private async void ButtonZmienZakres_Click(object sender, RoutedEventArgs e)
        {
            string s = textBoxTuWpiszLiczbe.Text;

            if (Int32.TryParse(s, out int result))
            {
                await Task.Run(() => PrimeNumbersGenerator.GetSingleton().FindPrimesTo(result));

                await textBoxInfoOZakresie.Dispatcher.InvokeAsync(
                    () => textBoxInfoOZakresie.Text = $"Aktualny zakres Liczb Pierwszych do: {result})");
            }
        }
Beispiel #6
0
 public void ArePrimesNumbersToStringEqualsToExpectedStringOfPrimes()
 {
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(1).ToString().Equals(""));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(2).ToString().Equals("2"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(3).ToString().Equals("2 3"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(4).ToString().Equals("2 3"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(5).ToString().Equals("2 3 5"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(6).ToString().Equals("2 3 5"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(7).ToString().Equals("2 3 5 7"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(8).ToString().Equals("2 3 5 7"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(9).ToString().Equals("2 3 5 7"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(10).ToString().Equals("2 3 5 7"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(11).ToString().Equals("2 3 5 7 11"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(12).ToString().Equals("2 3 5 7 11"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(13).ToString().Equals("2 3 5 7 11 13"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(30).ToString().Equals(
                       "2 3 5 7 11 13 17 19 23 29"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(100).ToString().Equals(
                       "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(200).ToString().Equals(
                       "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 " +
                       "101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199"));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(500).ToString().Equals(
                       "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 " +
                       "101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 " +
                       "211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 " +
                       "337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 " +
                       "461 463 467 479 487 491 499"
                       ));
     Assert.IsTrue(PrimeNumbersGenerator.GetSingleton().FindPrimesTo(1000).ToString().Equals(
                       "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 " +
                       "101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 " +
                       "211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 " +
                       "337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 " +
                       "461 463 467 479 487 491 499 " +
                       "503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 " +
                       "643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 " +
                       "797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 " +
                       "947 953 967 971 977 983 991 997"));
 }
Beispiel #7
0
 private async void WyswietlLiczbyPierwsze()
 {
     await Task.Run(() => textBoxDoWyswietlaniaLiczbPierwszych.Dispatcher.InvokeAsync(
                        () => textBoxDoWyswietlaniaLiczbPierwszych.Text = PrimeNumbersGenerator.GetSingleton().ToString()));
 }