public void RollOne([Values(0.1f, 0.35f, 0.5f, 0.6f, 0.8f, 1f)] float chance) { var dependentRandom = DependentRandom.Create(); var systemRandom = new SystemRandom(12323542); var dependentRandomLongestRow = 0; var systemRandomLongestRow = 0; var iterationCount = 1000000; var key = "someEventKey" + chance; var dependentInfo = new RollInfo(); var systemInfo = new RollInfo(); for (var i = 0; i < iterationCount; i++) { dependentInfo.Update(dependentRandom.Roll(key, chance)); systemInfo.Update(systemRandom.GetValue() < chance); } Assert.AreEqual(chance, dependentInfo.GetChance(), Delta); Assert.AreEqual(chance, systemInfo.GetChance(), Delta); Console.WriteLine(string.Format("Dependent random chance = {0}, max row = {1}", dependentInfo.GetChance(), dependentInfo.MaxRow)); Console.WriteLine(string.Format("System random chance = {0}, max row = {1}", systemInfo.GetChance(), systemInfo.MaxRow)); }
public void BinarySerializationTest() { var random = DependentRandom.Create(FileName); var eventName = "testEvent"; random.Roll(eventName, 0.5f); random.Dispose(); Assert.IsTrue(File.Exists(FileName)); var serializer = new BinaryRollHistorySerializer(FileName); var history = serializer.Deserialize(); Assert.IsTrue(history.HistoryStorage.ContainsKey(eventName)); }