protected override void EstablishContext() { controlDevice = A.Fake <ISpiControlDevice>(); controlDevice .CallsTo(device => device.Control(A <uint> .Ignored, A <SpiTransferControlStructure[]> .Ignored)) .Returns(IOCTL_PINVOKE_RESULT_CODE); connection = new NativeSpiConnection(controlDevice); // SPI control structure we expect to see during the P/Invoke call controlStructure = new SpiTransferControlStructure { BitsPerWord = BITS_PER_WORD, Length = 5, Delay = DELAY, ChipSelectChange = 1, Speed = SPEED_IN_HZ }; buffer = A.Fake <ISpiTransferBuffer>(); buffer .CallsTo(b => b.ControlStructure) .Returns(controlStructure); // setup fake collection to return our "prepared" fake buffer collection = A.Fake <ISpiTransferBufferCollection>(); collection .CallsTo(c => c.Length) .Returns(1); collection .CallsTo(c => c.GetEnumerator()) .ReturnsLazily(call => new List <ISpiTransferBuffer> { buffer }.GetEnumerator()); }
protected override void EstablishContext() { // SPI control structure we expect to see during the P/Invoke call controlStructure = new SpiTransferControlStructure { BitsPerWord = BITS_PER_WORD, Length = 5, Delay = DELAY, ChipSelectChange = 1, Speed = SPEED_IN_HZ }; controlDevice = A.Fake <ISpiControlDevice>(); controlDevice .CallsTo(device => device.Control(A <uint> .Ignored, ref controlStructure)) .WithAnyArguments() .Returns(IOCTL_PINVOKE_RESULT_CODE); connection = new NativeSpiConnection(controlDevice); buffer = A.Fake <ISpiTransferBuffer>(); buffer .CallsTo(b => b.ControlStructure) .Returns(controlStructure); }
protected override void EstablishContext() { // SPI control structure we expect to see during the P/Invoke call controlStructure = new SpiTransferControlStructure { BitsPerWord = BITS_PER_WORD, Length = 5, Delay = DELAY, ChipSelectChange = 1, Speed = SPEED_IN_HZ }; controlDevice = A.Fake<ISpiControlDevice>(); controlDevice .CallsTo(device => device.Control(A<uint>.Ignored, ref controlStructure)) .WithAnyArguments() .Returns(IOCTL_PINVOKE_RESULT_CODE); connection = new NativeSpiConnection(controlDevice); buffer = A.Fake<ISpiTransferBuffer>(); buffer .CallsTo(b => b.ControlStructure) .Returns(controlStructure); }
protected override void EstablishContext() { controlDevice = A.Fake<ISpiControlDevice>(); controlDevice .CallsTo(device => device.Control(A<uint>.Ignored, A<SpiTransferControlStructure[]>.Ignored)) .Returns(IOCTL_PINVOKE_RESULT_CODE); connection = new NativeSpiConnection(controlDevice); // SPI control structure we expect to see during the P/Invoke call controlStructure = new SpiTransferControlStructure { BitsPerWord = BITS_PER_WORD, Length = 5, Delay = DELAY, ChipSelectChange = 1, Speed = SPEED_IN_HZ }; buffer = A.Fake<ISpiTransferBuffer>(); buffer .CallsTo(b => b.ControlStructure) .Returns(controlStructure); // setup fake collection to return our "prepared" fake buffer collection = A.Fake<ISpiTransferBufferCollection>(); collection .CallsTo(c => c.Length) .Returns(1); collection .CallsTo(c => c.GetEnumerator()) .ReturnsLazily(call => new List<ISpiTransferBuffer>{buffer}.GetEnumerator()); }