public void BuildMatrixTest() { //Arrange IMatrixSolver matrixSolver = new MatrixSolver(); Decode_Accessor target = new Decode_Accessor(matrixSolver); IList<Drop> drops = new Drop[3] { new Drop(){SelectedParts=new int[2]{0,1},Data=new byte[2]{1,2}}, new Drop(){SelectedParts=new int[2]{0,2},Data=new byte[2]{3,4}}, new Drop(){SelectedParts=new int[2]{1,2},Data=new byte[2]{5,6}} }; var expected = new int[6, 7] { {1,0,1,0,0,0,1}, {0,1,0,1,0,0,2}, {1,0,0,0,1,0,3}, {0,1,0,0,0,1,4}, {0,0,1,0,1,0,5}, {0,0,0,1,0,1,6} }; int blocksCount = 3; int chunkSize = 2; //Act var actual = target.BuildMatrix(drops, blocksCount, chunkSize); //Assert Common.CheckArraysAreEqual(expected, actual); }
public void StartReceivingExecuteTest() { //Arrange Mock<IDecode> decodeMock = new Mock<IDecode>(); Mock<IEncodeService> encodeServiceMock = new Mock<IEncodeService>(); var drop = new Drop { Data = new byte[4] { 7, 0, 2, 0 }, SelectedParts = new int[2] { 1, 2 } }; encodeServiceMock.Setup(m => m.Encode()).Returns(drop); DecoderViewModel decoderViewModel = new DecoderViewModel(decodeMock.Object, encodeServiceMock.Object); //Act decoderViewModel.StartReceiving.Execute(null); //Assert decodeMock.Verify(m => m.Decode(It.IsAny<IList<Entities.Drop>>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Once()); }