コード例 #1
0
        public void ShouldWaitUntilImagePixelsAreObtained()
        {
            // Given
            var imageModel = new ImageModel(1024, 768, ImageBitDepth.Bpp12);
            var packetSimulationEnumerator = TestDataSource.SimulateSendingOfDummyImageWithStartMidwayOfSendingAnImage(imageModel).GetEnumerator();

            var udpClientMock = new Mock <IUdpClient>();

            udpClientMock.Setup(r => r.Receive()).Returns(() =>
            {
                packetSimulationEnumerator.MoveNext();
                return(packetSimulationEnumerator.Current);
            });

            var imageProvider = new CameraImageProvider(imageModel, udpClientMock.Object);

            // When
            Image actualImage;

            imageProvider.TryToObtainImage(out actualImage);

            // Then
            var expectedImage = TestDataSource.GetExpectedDummyImage(imageModel);

            Assert.AreEqual(expectedImage, actualImage);
        }
コード例 #2
0
        public void ShouldThrowExceptionWhenUnsupportedParametersAreUsed()
        {
            // Given
            var imageModel = new ImageModel(1024, 1024, ImageBitDepth.Bpp8);

            var udpClient = PrepareUdpClientMock(imageModel);

            var imageProvider = new CameraImageProvider(imageModel, udpClient);

            // When
            // Then
            Image actualImage;

            imageProvider.TryToObtainImage(out actualImage);
        }
コード例 #3
0
        public void ShouldThrowExceptionWhenDifferentImageIsReceivedThanRequested()
        {
            // Given
            var requestedImageModel = new ImageModel(1024, 768, ImageBitDepth.Bpp8);
            var actualImageModel    = new ImageModel(1024, 768, ImageBitDepth.Bpp12);

            var udpClient = PrepareUdpClientMock(actualImageModel);

            var imageProvider = new CameraImageProvider(requestedImageModel, udpClient);

            // When
            // Then
            Image actualImage;

            imageProvider.TryToObtainImage(out actualImage);
        }
コード例 #4
0
        public void ShouldReturnCorrectImageWhenUsing12BppModel()
        {
            // Given
            var imageModel = new ImageModel(1024, 768, ImageBitDepth.Bpp12);

            var udpClient = PrepareUdpClientMock(imageModel);

            var imageProvider = new CameraImageProvider(imageModel, udpClient);

            // When
            Image actualImage;

            imageProvider.TryToObtainImage(out actualImage);

            // Then
            var expectedImage = TestDataSource.GetExpectedDummyImage(imageModel);

            Assert.AreEqual(expectedImage, actualImage);
        }
コード例 #5
0
        public void ShouldReturnEmptyImageWhenNoPixelsWhereSent()
        {
            // Given
            var udpClientMock = new Mock <IUdpClient>();
            var imageModel    = new ImageModel(1024, 768, ImageBitDepth.Bpp8);

            udpClientMock.Setup(uc => uc.Receive()).Returns(Encoding.ASCII.GetBytes("START"));
            var imageProvider = new CameraImageProvider(imageModel, udpClientMock.Object);

            // When
            Image actualImage;

            imageProvider.TryToObtainImage(out actualImage);

            // Then
            var expectedImage = new Image(imageModel);

            Assert.AreEqual(expectedImage, actualImage);
        }