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); }
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); }
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); }
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); }
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); }