-
Notifications
You must be signed in to change notification settings - Fork 1
/
SelectionSamplingTests.cs
48 lines (41 loc) · 1.37 KB
/
SelectionSamplingTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using AlgorithmsAndDataStructures.Algorithms.Sampling;
using System;
using System.Linq;
using Xunit;
namespace AlgorithmsAndDataStructures.Tests.Algorithm.Sampling
{
public class SelectionSamplingTests
{
[Fact]
public void CanSelectSample()
{
var sut = new SelectionSampling();
var population = new[] { 1, 2 };
const int sampleSize = 1;
var sample = sut.GetRandomSample(population, sampleSize);
Assert.True(sample[0] != 0);
}
[Fact]
public void ThrowsOnIncorrectParams()
{
var sut = new SelectionSampling();
var population = new[] { 1, 2 };
const int sampleSize = 3;
Assert.Throws<ArgumentException>(() => sut.GetRandomSample(population, sampleSize));
}
[Fact]
public void Fuzzy()
{
var sut = new SelectionSampling();
var random = new Random();
var population = new int[100];
for (var i = 0; i < population.Length; i++)
{
population[i] = random.Next(1, 10000);
}
var sampleSize = random.Next(1,100);
var sample = sut.GetRandomSample(population, sampleSize);
Assert.True(sample.All(arg => arg != 0));
}
}
}