Esempio n. 1
0
        public void GenerateIndexToSend_WhenCalledForRequestBehaviourOn15_ShouldSend0(byte data, bool isResponseBehaviour, int indexValue)
        {
            _sut = new IndexerCalculator(isResponseBehaviour);
            byte firstByte = 0b1110_0000;

            for (int i = 0; i++ < indexValue;)
            {
                _sut.GenerateIndexToSend(firstByte);
            }

            var result = _sut.GenerateIndexToSend(firstByte);

            Assert.Equal(data, result);
        }
Esempio n. 2
0
        public void GenerateIndexToSend_WhenCalledForRequestBehaviour_ShouldSendNextValue()
        {
            _sut = new IndexerCalculator(false);
            byte firstByte = 0b0101_0000;

            var result = _sut.GenerateIndexToSend(firstByte);

            Assert.Equal(0b0101_0001, result);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }