Пример #1
0
        public void NumeralSystemConverter_DecimalToBase13_Test()
        {
            //Assign
            var numeralSystemConverter = new NumeralSystemConverter();
            Dictionary <int, string> decimalBase13Set = new Dictionary <int, string>()
            {
                { 0, "0" }, { 1, "1" }, { 9, "9" }, { 10, "A" }, { 11, "B" }, { 12, "C" }, { 13, "10" }, { 14, "11" }, { 15, "12" }, { 16, "13" }
            };

            foreach (var decimalBase13Pair in decimalBase13Set)
            {
                //Act
                var result = numeralSystemConverter.DecimalToArbitrarySystem(decimalBase13Pair.Key, 13);
                //Asert
                Assert.Equal(decimalBase13Pair.Value, result);
            }
        }
        public void NumeralSystemAndGeneratorIntegrationTest_NotEqual_Test()
        {
            //Assign
            var primeNumberInBase13HardCoded = new List <string>()
            {
                "2", "3", "5", "7", "A", "10"
            };
            var numeralSystemConverter = new NumeralSystemConverter();
            var primeNumberGenerator   = new PrimeNumberGeneratorNaive();
            //Act
            var primeNumberGeneratedInBase13 = new List <string>();

            foreach (long primeNumber in primeNumberGenerator.ExecuteWithYield(primeNumberInBase13HardCoded.Count))
            {
                primeNumberGeneratedInBase13.Add(numeralSystemConverter.DecimalToArbitrarySystem(primeNumber, 13));
            }
            var result = (primeNumberGeneratedInBase13.Count == primeNumberInBase13HardCoded.Count &&
                          (!primeNumberGeneratedInBase13.Except(primeNumberInBase13HardCoded).Any() || !primeNumberInBase13HardCoded.Except(primeNumberGeneratedInBase13).Any()));

            //Assert
            Assert.False(result);
        }