public void ConvertToPNG_Called_CreatesPNGCorrectly()
        {
            //Arrange
            ImageSize imageSize = new ImageSize(1, 2);

            svgDocument.Width  = new SvgUnit(SvgUnitType.Pixel, imageSize.Width);
            svgDocument.Height = new SvgUnit(SvgUnitType.Pixel, imageSize.Height);

            mockFileSystemProvider.Setup(x => x.GetDirectoryName(file)).Returns(saveLocation);
            mockFileSystemProvider.Setup(x => x.GetFileNameWithoutExtension(file)).Returns(fileNameWithoutExtension);
            mockSVGDocumentWrapper.Setup(x => x.GetDocument(It.IsAny <string>(), It.IsAny <SvgAspectRatio>())).Returns(svgDocument);

            sut = CreateValidSVGConverter();

            var outputLocation = ReflectionUtilities.ExecutePrivateMethod <SVGToPNGConverter, string>(sut, "GetOutputLocation",
                                                                                                      new object[] { file, saveLocation });
            var expectedFileName = ReflectionUtilities.ExecutePrivateMethod <SVGToPNGConverter, string>(sut, "GetFileSaveLocation",
                                                                                                        new object[] { file, outputLocation, imageSize });

            //Act
            sut.Convert(file, imageSize, saveLocation);

            //Assert
            mockBitmapWrapper.Verify(x => x.CreatePNG(expectedFileName, svgDocument, imageSize.ToSize()));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Show Dialog
 /// </summary>
 /// <param name="sender">sender control</param>
 /// <param name="resolution">image size</param>
 /// <returns>filepath of photo</returns>
 public static FileInfo ShowDialog(Control sender, ImageSize resolution)
 {
     if (SystemState.CameraPresent && SystemState.CameraEnabled)
     {
         using (CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog())
         {
             cameraCaptureDialog.Owner = sender;
             cameraCaptureDialog.Mode = CameraCaptureMode.Still;
             cameraCaptureDialog.StillQuality = CameraCaptureStillQuality.Normal;
             cameraCaptureDialog.Title = "takeIncidentPhoto".Translate();
             if (resolution != null)
             {
                 cameraCaptureDialog.Resolution = resolution.ToSize();
             }
             if (cameraCaptureDialog.ShowDialog() == DialogResult.OK)
             {
                 return new FileInfo(cameraCaptureDialog.FileName);
             }
         }
     }
     else
     {
         using(OpenFileDialog openFileDialog = new OpenFileDialog())
         {
             openFileDialog.Filter = "JPEG (*.jpg,*.jpeg)|*.jpg;*.jpeg";
             if (openFileDialog.ShowDialog() == DialogResult.OK)
             {
                 return new FileInfo(openFileDialog.FileName);
             }
         }
     }
     return null;
 }