public void ProductOfAAndBInQuadradicThatGeneratesMostPrimes_IsNegative59231() { var primeService = new PrimeService(); var result = Sequences .NaturalNumbers() .Select(n => n - 1000) .Take(2001) .FullJoin( Sequences .NaturalNumbers() .Select(n => n - 1000) .Take(2001), (a, b) => (a: a, b: b)) .Select(quadratic => ( quadratic: quadratic, primeCount: Sequences .NaturalNumbers() .Select(Operations.QuadraticFunction(quadratic.a, quadratic.b)) .TakeWhile(primeService.IsPrime) .Count())) .OrderByDescending(quadResult => quadResult.primeCount) .Select(quadResult => quadResult.quadratic.a * quadResult.quadratic.b) .First(); Assert.AreEqual(-59231, result); }
public void IsPrime_ValuesLessThan2_ReturnFalse(int value) { var primeService = new PrimeService(); var result = primeService.IsPrime(value); Assert.False(result, $"{value} should not be prime"); }
public PrimeService_IsPrimeShould() { mock.Setup(x => x.IsTrue()).Returns(false); _primeService = new PrimeService(mock.Object); //_primeService = new PrimeService(); }
public void TestMethod1() { var primeService = new PrimeService(); bool result = primeService.IsPrime(1); Assert.IsFalse(result, "1 should not be prime"); }
public void ReturnTruePrimesWithClassDataFromPrimeDataGenerator(params int[] list) { foreach (int t in list) { Assert.True(PrimeService.IsPrime(t)); } }
public void Test2() { var primeService = new PrimeService(); bool result = primeService.IsPrime(1); Assert.True(result, "1 should not be prime"); }
public void Given_LessThanOneArraySize_Then_Return_EmptyArray(int arraySize) { IPrimeService primeNumbers = new PrimeService(); var primeArray = primeNumbers.GetPrimeNumbers(arraySize); Assert.Empty(primeArray); }
public void IsNotPrimeTest(int value) { PrimeService primeService = CreatePrimeService(); var result = primeService.IsPrime(value); Assert.IsFalse(result, $"{value} is prime"); }
public void AllNumbersAreNotPrimeWithMemberDataFromPrimeDataGenerator(params int[] list) { foreach (int t in list) { Assert.False(PrimeService.IsPrime(t)); } }
public void IsPrime_InputIs1_ReturnFalse() { var primeService = new PrimeService(); bool result = primeService.IsPrime(1); Assert.IsFalse(result); }
public void IsPrime_InputisNegative1_ReturnFalse() { var primeService = new PrimeService(); bool result = primeService.IsPrime(-1); Assert.False(result, "-1 should not be prime"); }
public void IsPrime_InputIs1_ReturnFalse() { var primeService = new PrimeService(); bool result = primeService.IsPrime(1); Assert.False(result, "1 should not be prime"); }
private void btnCheck_Click(object sender, EventArgs e) { PrimeService primeService = new PrimeService(); try { int num = int.Parse(tbNum.Text); if (num < 2 || num > int.MaxValue) { throw new Exception(); } var result = primeService.IsPrime(num); if (result) { lblAns.ForeColor = Color.Green; lblAns.Text = "Yes"; } else { lblAns.ForeColor = Color.Red; lblAns.Text = "No"; } } catch (Exception) { MessageBox.Show("Write correct data!"); } }
static void Main(string[] args) { int number = 0; while (true) { Console.Write("Enter size of Prime Numbers Multiplication Table: "); if (Int32.TryParse(Console.ReadLine(), out number)) { if (number >= 1) { break; } else { InvalidNumberError(); } } else { InvalidNumberError(); } } ; IPrimeService myPrimeCalculator = new PrimeService(); IPrint consoleDisplay = new ConsolePrint(); var primeNumbers = myPrimeCalculator.GetPrimeNumbers(number).ToArray(); var primeArray = myPrimeCalculator.GetPrimeMultiplcationTable(primeNumbers); consoleDisplay.Print(primeArray); Console.ReadKey(); }
public void TwoIsPrime() { var primeService = new PrimeService(); var result = primeService.IsPrime(2); Assert.True(result, "2 should be prime"); }
public void Given_ValidArraySize_Then_DoNotReturn_CompositeNumbers(int arraySize) { IPrimeService primeNumbers = new PrimeService(); var primeArray = primeNumbers.GetPrimeNumbers(arraySize); Assert.Equal(arraySize, primeArray.Count); Assert.DoesNotContain(4, primeArray); }
public void Given_ValidArraySize_Then_Return_PrimeNumbers(int arraySize) { IPrimeService primeNumbers = new PrimeService(); var primeArray = primeNumbers.GetPrimeNumbers(arraySize); Assert.Equal(arraySize, primeArray.Count); Assert.Contains(2, primeArray); }
public void IsPrime_CompositeNumber_ReturnsFalse(int number) { var primeService = new PrimeService(); var result = primeService.IsPrime(number); Assert.False(result); }
public void IsPrime_PrimeNumber_ReturnsTrue(int number) { var primeService = new PrimeService(); var result = primeService.IsPrime(number); Assert.True(result); }
public void OneIsNotPrime() { var primeService = new PrimeService(); var result = primeService.IsPrime(1); Assert.False(result, "1 should not be prime"); }
public void ShouldThrowIfValidatorIsNull() { var resolver = new Mock <IPrimeFacilitiesResolver>(); var logger = new Mock <ILog>(); var validator = (IValidator <MethodIdNumberPairContainer>)null; var result = new PrimeService(resolver.Object, logger.Object, validator); }
public void Given_GreaterThanOneInput_Then_Return_CorrectArrayCount() { var arraySize = 5; IPrimeService primeNumbers = new PrimeService(); var primeArray = primeNumbers.GetPrimeNumbers(arraySize); Assert.Equal(arraySize, primeArray.Count); }
public async Task CanGet() { var primeService = new PrimeService(); var controller = new PrimeController(primeService); var response = (OkObjectResult)await controller.Get(); _output.WriteLine($"{response.Value}"); response.ShouldNotBeNull(); }
public void NumberOfPrimeRoationsBelow100_Is13() { var primeService = new PrimeService(); var result = Sequences.NumbersBetween(2, 100) .Where(num => num.ToDigitRotations().AllPrime(primeService)) .Count(); Assert.AreEqual(13, result); }
public void Given_EmptyInputArray_Then_Return_Null() { int[] array = { }; IPrimeService primeNumbers = new PrimeService(); var primeArray = primeNumbers.GetPrimeMultiplcationTable(array); Assert.Null(primeArray); }
public void GetPrimeFactors_CompositeNumber_ReturnsCorrectPrimeFactors(int number) { var primeService = new PrimeService(); var primeFactorService = new PrimeFactorService(primeService); var result = primeFactorService.GetPrimeFactors(number); Assert.Equal(number, result.Aggregate(1, (x, y) => x * y)); Assert.All(result, x => primeService.IsPrime(x)); }
public void Given_ValidInputArray_Then_Return_CorrectTableMatrixCount() { int[] array = { 2, 3, 5, 7 }; IPrimeService primeNumbers = new PrimeService(); var primeArray = primeNumbers.GetPrimeMultiplcationTable(array); Assert.Equal(array.Length + 1, primeArray.GetLength(0)); Assert.Equal(array.Length + 1, primeArray.GetLength(1)); }
public void IsPrime_ValuesLessThan2_ReturnFalse(int value) { // Arrange var primeService = new PrimeService(); // Act var result = primeService.IsPrime(value); // Assert result.Should().BeFalse($"{value} should not be prime"); }
public void IsPrime_InputIs3_ReturnTrue() { // Arrange var primeService = new PrimeService(); // Act bool result = primeService.IsPrime(3); // Assert result.Should().BeTrue(); }
public void RotationsOf197_AreAllPrime() { var primeService = new PrimeService(); var result = new BigInteger(197) .ToDigitRotations(); var result2 = result .AllPrime(primeService); Assert.IsTrue(result2); }