public void ShouldTestAnd() { var probability = new Probability(1.0); var probabilityHalf = new Probability(0.5); Assert.That(probability,Is.EqualTo(probability.And(probability))); Assert.That(probabilityHalf,Is.EqualTo(probability.And(probabilityHalf))); Assert.That(new Probability(0.25),Is.EqualTo(probabilityHalf.And(probabilityHalf))); }
public void ShouldTestEquals() { var probabilityOne = new Probability(0.5); Assert.That(probabilityOne,Is.EqualTo(probabilityOne)); Assert.True(probabilityOne.Equals(new Probability(0.5))); Assert.False(probabilityOne.Equals(new Probability(1.0))); Assert.False(probabilityOne.Equals(null)); Assert.False(probabilityOne.Equals(new object())); }
public Probability And(Probability probability) { return new Probability(valueAsFraction*probability.valueAsFraction); }