Ejemplo n.º 1
0
        public void CheckRecords_1()
        {
            // TAKE N x N matrix
            const int COUNT      = 3;
            const int EXPECTED_1 = 1000;
            var       row        = new ushort[] { EXPECTED_1, EXPECTED_1, EXPECTED_1 };
            var       slicer     = new Mock <ISlicer>();
            var       secondary  = new Mock <IRowValleyOptimizer>();
            var       optimizer  = new MatrixOptimizer(slicer.Object, secondary.Object);
            var       result     = optimizer.Investigate1DArray(0, row);

            Assert.AreEqual(COUNT, result.NoOfStates);
            Assert.AreEqual(COUNT, result.NoOfNonZeroPercents);
            Assert.AreEqual(0, result.NoOfZeroPercents);

            Assert.IsNotNull(result.Clusters);
            Assert.AreEqual(1, result.Clusters.Length);

            {
                var record = result.Clusters[0];

                Assert.AreEqual(EXPECTED_1, record.Value);
                Assert.AreEqual(0, record.First);
                Assert.AreEqual(COUNT, record.NoOfTimes);
            }
        }
Ejemplo n.º 2
0
        public void CheckAllZeros_SingleRow()
        {
            var slicer    = new Mock <ISlicer>();
            var secondary = new Mock <IRowValleyOptimizer>();
            var optimizer = new MatrixOptimizer(slicer.Object, secondary.Object);

            // TAKE N x N matrix
            const int COUNT  = 8;
            var       row    = new ushort[COUNT];
            var       result = optimizer.Investigate1DArray(0, row);

            Assert.AreEqual(COUNT, result.NoOfStates);
            Assert.AreEqual(0, result.NoOfNonZeroPercents);
            Assert.AreEqual(COUNT, result.NoOfZeroPercents);
            Assert.IsFalse(result.SelfPercent.HasValue);
        }
Ejemplo n.º 3
0
        public void CheckRecords_Empty()
        {
            // TAKE N x N matrix
            const int COUNT     = 0;
            var       row       = new ushort[] { };
            var       slicer    = new Mock <ISlicer>();
            var       secondary = new Mock <IRowValleyOptimizer>();
            var       optimizer = new MatrixOptimizer(slicer.Object, secondary.Object);
            var       result    = optimizer.Investigate1DArray(0, row);

            Assert.AreEqual(COUNT, result.NoOfStates);
            Assert.AreEqual(COUNT, result.NoOfNonZeroPercents);
            Assert.AreEqual(0, result.NoOfZeroPercents);

            Assert.IsNotNull(result.Clusters);
            Assert.AreEqual(0, result.Clusters.Length);
        }
Ejemplo n.º 4
0
        public void CheckAlNonZeros_SingleRow()
        {
            // TAKE N x N matrix
            const int    COUNT        = 4;
            const ushort SELF_PERCENT = 100;
            var          row          = new ushort[] { SELF_PERCENT, 200, 300, 400 };
            var          slicer       = new Mock <ISlicer>();
            var          secondary    = new Mock <IRowValleyOptimizer>();
            var          optimizer    = new MatrixOptimizer(slicer.Object, secondary.Object);
            var          result       = optimizer.Investigate1DArray(0, row);

            Assert.AreEqual(COUNT, result.NoOfStates);
            Assert.AreEqual(COUNT, result.NoOfNonZeroPercents);
            Assert.AreEqual(0, result.NoOfZeroPercents);
            Assert.IsTrue(result.SelfPercent.HasValue);
            Assert.AreEqual(SELF_PERCENT, result.SelfPercent.Value);
        }