public void GenerateQRCodeSuccessfulTest() { string imageFormat = "png"; string eccl = QRCodeGenerator.ECCLevel.H.ToString("G"); string output = Path.Combine(Path.GetTempPath(), "output.png"); const bool eraseExistingFile = true; const bool forceUtf8 = true; const int pixelPerModule = 20; GenerateQRCodeAction action = new GenerateQRCodeAction() { ImageFormat = imageFormat, ErrorCorrectLevel = eccl, OutputFilePath = output, EraseExistingFile = eraseExistingFile, ForceUtf8 = forceUtf8, PixelPerModule = pixelPerModule }; var actionResult = action.Execute(ArgumentCollection.New() .WithArgument(GenerateQRCodeActionExecutionArgs.PlainText, qrCodeContent)); Assert.IsNotNull(actionResult); Assert.IsTrue(actionResult.Result); Assert.IsTrue(File.Exists(output)); File.Delete(output); }
public GenerateQRCodeActionConfiguratorViewModel() { EccLevels = new ObservableCollection <QRCodeGenerator.ECCLevel>(Enum.GetValues <QRCodeGenerator.ECCLevel>()); ImageFormats = new ObservableCollection <string>(GenerateQRCodeAction.AllowedImageFormats()); PixelPerModuleList = new ObservableCollection <int>(Enumerable.Range(GenerateQRCodeAction.MinPixelPerModule, GenerateQRCodeAction.MaxPixelPerModule)); SelectOutputPathCommand = new RelayCommand(SelectOutputPath); }
public void GenerateQRCodeFailsOnWrongOrEmptyImageFormat() { string imageFormat = "routindo"; string eccl = QRCodeGenerator.ECCLevel.H.ToString("G"); string output = Path.Combine(Path.GetTempPath(), "output.png"); const bool eraseExistingFile = true; const bool forceUtf8 = true; const int pixelPerModule = 20; GenerateQRCodeAction action = new GenerateQRCodeAction() { ImageFormat = imageFormat, ErrorCorrectLevel = eccl, OutputFilePath = output, EraseExistingFile = eraseExistingFile, ForceUtf8 = forceUtf8, PixelPerModule = pixelPerModule }; var actionResult = action.Execute(ArgumentCollection.New() .WithArgument(GenerateQRCodeActionExecutionArgs.PlainText, qrCodeContent)); Assert.IsNotNull(actionResult); Assert.IsFalse(actionResult.Result); Assert.IsNotNull(actionResult.AttachedException); Assert.IsFalse(File.Exists(output)); imageFormat = string.Empty; action.ImageFormat = imageFormat; actionResult = action.Execute(ArgumentCollection.New() .WithArgument(GenerateQRCodeActionExecutionArgs.PlainText, qrCodeContent)); Assert.IsNotNull(actionResult); Assert.IsFalse(actionResult.Result); Assert.IsNotNull(actionResult.AttachedException); Assert.IsFalse(File.Exists(output)); }