Exemplo n.º 1
0
        public void AddingToAQuantumUpdatesTheTotal()
        {
            var q = new Quantization1i(10);

            q[0] += 1;
            q.Total.Should().Be(1);
        }
Exemplo n.º 2
0
        public void WhenMultiplyingByAFloat_EachValueIsMultipliedCorrectly()
        {
            var q = new Quantization1i(new[] { 0, 1, 53, 12, 2 });

            var result = q * 0.5f;

            result.GetValues().Should().BeEquivalentTo(new[] { 0, 0.5f, 26.5f, 6, 1 });
        }
Exemplo n.º 3
0
        public void QuantumProbabilityIsCalculatedCorrectly(int quantizations, int quantum, float expectedProbability)
        {
            var q = new Quantization1i(quantizations);

            var probability = q.GetQuantumProbability(quantum);

            probability.Should().Be(expectedProbability);
        }
Exemplo n.º 4
0
        public void IfTwoQuantizationsHaveDifferentLengths_AnExceptionIsThrown()
        {
            var q1 = new Quantization1i(10);
            var q2 = new Quantization1i(11);

            new Func <Quantization1i>(() => q1 + q2)
            .Should().ThrowExactly <QuantizationsMismatchException <int> >();
        }
        public void PassedInValuesAreUsed()
        {
            var q = new Quantization1i(new[] { 5, 1, 9 });

            q[-1].Should().Be(5);
            q[0].Should().Be(1);
            q[1].Should().Be(9);
        }
Exemplo n.º 6
0
        public void AbleToAddTwoQuantizationsTogether()
        {
            var q1 = new Quantization1i(new[] { 1, 2, 3, 4, 5 });
            var q2 = new Quantization1i(new [] { 10, 100, 30, 14, 11 });

            var result = q1 + q2;

            result.GetValues().Should().BeEquivalentTo(new[] { 11, 102, 33, 18, 16 });
        }
Exemplo n.º 7
0
        public void WhenMultiplying_TheOriginalValueIsUnchanged()
        {
            var q = new Quantization1i(new[] { 0, 1, 10 });

            var result = q * 5;

            result[0].Should().Be(5);
            q[0].Should().Be(1);
        }
Exemplo n.º 8
0
        public void AbleToMultipleAQuantizationByAnInteger()
        {
            var q = new Quantization1i(new[] { 0, 1, 10 });

            var result = q * 5;

            result[-1].Should().Be(0);
            result[0].Should().Be(5);
            result[1].Should().Be(50);
        }
Exemplo n.º 9
0
        public void ASimpleEvenQuantizationHasAnEvenDistribution()
        {
            var q = new Quantization1i(new [] { 2, 2, 2 });

            var distribution = q.GetDistribution();

            distribution[-1].Should().BeApproximately(0.333f, 0.0001f);
            distribution[0].Should().BeApproximately(0.333f, 0.0001f);
            distribution[1].Should().BeApproximately(0.333f, 0.0001f);
        }
Exemplo n.º 10
0
        public void ANewlyCreatedQuantizationIsEmpty()
        {
            var q = new Quantization1i(10);

            q.Total.Should().Be(0);
        }
Exemplo n.º 11
0
        public void InitializingThroughTheConstructorUpdatesTotal()
        {
            var q = new Quantization1i(new[] { 1, 2, 3 });

            q.Total.Should().Be(6);
        }