Example #1
0
        public void GetIndex()
        {
            // arrange
            var layout          = new Layout(new[] { 3, 4 }, 5, new[] { 4, 1 });
            var hostStorageMock = new Mock <IHostStorage <int> >();

            hostStorageMock.SetupGet(m => m.Data).Returns(Enumerable.Range(0, 12).ToArray());
            var hostBackend = new HostBackend <int>(layout, hostStorageMock.Object);

            // action
            var index = new[] { 1, 2 };
            var val   = hostBackend[index];

            // assert
            // 5 + (4 * 1) + 2
            Assert.AreEqual(11, val);
        }
Example #2
0
        public void SetIndex()
        {
            // arrange
            var layout          = new Layout(new[] { 3, 4 }, 5, new[] { 4, 1 });
            var hostStorageMock = new Mock <IHostStorage <int> >();
            var memory          = new int[12];

            hostStorageMock.SetupGet(m => m.Data).Returns(memory);
            var hostBackend = new HostBackend <int>(layout, hostStorageMock.Object);

            // action
            var index = new[] { 1, 2 };

            hostBackend[index] = 999;

            // assert
            // 5 + (4 * 1) + 2
            Assert.AreEqual(999, memory[11]);
            Assert.AreEqual(999, memory.Aggregate(0, (a, b) => a + b));
        }