Repository navigation
Expand file tree
/
Copy pathReproductionTests.cs
More file actions
40 lines (35 loc) · 1.48 KB
/
Copy pathReproductionTests.cs
File metadata and controls
40 lines (35 loc) · 1.48 KB
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
using System;
using GeneCodeCS.Test.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace GeneCodeCS.Test
{
[TestClass]
public class ReproductionTests
{
[TestMethod]
public void Rates_accept_values_from_0_to_100() {
var target = new Reproduction<CounterBot> { CrossoverRate = 0, MutationRate = 100, RandomBotPercentage = 50 };
Assert.AreEqual(0, target.CrossoverRate);
Assert.AreEqual(100, target.MutationRate);
Assert.AreEqual(50, target.RandomBotPercentage);
}
[TestMethod]
public void CrossoverRate_rejects_out_of_range_values() {
var target = new Reproduction<CounterBot>();
Assert.ThrowsException<ArgumentOutOfRangeException>(() => target.CrossoverRate = 101);
Assert.ThrowsException<ArgumentOutOfRangeException>(() => target.CrossoverRate = -1);
}
[TestMethod]
public void MutationRate_rejects_out_of_range_values() {
var target = new Reproduction<CounterBot>();
Assert.ThrowsException<ArgumentOutOfRangeException>(() => target.MutationRate = 101);
Assert.ThrowsException<ArgumentOutOfRangeException>(() => target.MutationRate = -1);
}
[TestMethod]
public void RandomBotPercentage_rejects_out_of_range_values() {
var target = new Reproduction<CounterBot>();
Assert.ThrowsException<ArgumentOutOfRangeException>(() => target.RandomBotPercentage = 101);
Assert.ThrowsException<ArgumentOutOfRangeException>(() => target.RandomBotPercentage = -1);
}
}
}