示例#1
0
        public void ValidateCurrentIndex_WhenCalledForResponseWithWrongValue_ShouldReturnFalse()
        {
            _sut = new IndexerCalculator(true);
            byte firstByte        = 0b1111_0000;
            var  validationResult = _sut.ValidateCurrentIndex(firstByte);

            Assert.False(validationResult);
        }
示例#2
0
        public void ValidateCurrentIndex_WhenCalledForRequestAfterGenerateIndexToSend_ShouldSendNextValue(byte data, bool expectedResult)
        {
            _sut = new IndexerCalculator(false);
            _sut.GenerateIndexToSend(0b1000_0000);

            var validationResult = _sut.ValidateCurrentIndex(data);

            Assert.Equal(expectedResult, validationResult);
        }
示例#3
0
        public void GenerateIndexToSend_WhenCalledForRequestAfterValidate_ShouldSendSameValue()
        {
            _sut = new IndexerCalculator(false);
            byte firstByte        = 0b1111_0000;
            var  validationResult = _sut.ValidateCurrentIndex(firstByte);

            var result = _sut.GenerateIndexToSend(firstByte);

            Assert.True(validationResult);
            Assert.Equal(0b1111_0001, result);
        }
示例#4
0
        public void GenerateIndexToSend_WhenCalledForRequest_ShouldBeValidOnResponce(
            int requestCurrentIndex,
            int responseCurrentIndex,
            bool expectedResult)
        {
            var  requestCalculator  = new IndexerCalculator(false, requestCurrentIndex);
            var  responseCalculator = new IndexerCalculator(true, responseCurrentIndex);
            byte firstByte          = Session.REQUEST;
            var  indexToSend        = requestCalculator.GenerateIndexToSend(firstByte);
            var  temp   = ByteToString(indexToSend);
            var  result = responseCalculator.ValidateCurrentIndex(indexToSend);

            Assert.Equal(expectedResult, result);
        }