Files
PowerToys/src/modules/previewpane/UnitTests-GcodeThumbnailProvider/GcodeThumbnailProviderTests.cs
Stefan Markovic 6ac508fb93 Self-contained .NET (#22217)
* dotnet sc

* MD preview - C# app

 - working self-contained

* Gcode preview - C# app

* DevFiles preview - C# app

* Fix passing path with spaces as cmd arg and monacocpp proj file

* Pdf preview - C# app

* Svg preview - C# app

* Fix comment

* Gcode thumbnail - C# app

TODO:
	- installer
	- why IThumbnailProvider and IIntializeWithFile doesn't work?

* Pdf thumbnail - C# app

TODO:
        - installer
        - why IThumbnailProvider and IIntializeWithFile doesn't work?

* Pdf thumbnail - C# app

TODO:
        - installer
        - why IThumbnailProvider and IIntializeWithFile doesn't work?

* Fix GcodeThumbnailProviderCpp.vcxproj

* Svg thumbnail - C# app

TODO:
        - installer
        - why IThumbnailProvider and IIntializeWithFile doesn't work?

* Fix Svg tests

* Thumbnail providers - installer

* Self-contained Hosts and FileLocksmith

* Fix hardcoded <RuntimeIdentifier>

* Remove unneeded files

* Try to fix Nuget in PR CI

* Prefix new dlls with PowerToys.
Sign new dlls and exes

* Add new .exe files to ProcessList

* ci: debug by listing all env vars

* ci: try setting variable in the right ci file

* Bring back hardcoded RuntimeIdentifier

* ci: Add comment and remove debug action

* Remove unneeded lib

* [WIP] Platform conditional dotnet files & hardlinks

* Cleanup

* Update expect.txt

* Test fix - ARM installer

* Fix uninstall bug

* Update docs

* Fix failing test

* Add dll details

* Minor cleanup

* Improve resizing

* Add some logs

* Test fix - release build

* Remove InvokeOnControlThread

* Test fix: logger initialization

* Fix arm64 installer

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2022-12-14 13:37:23 +01:00

78 lines
2.2 KiB
C#

// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Common.ComInterlop;
using Microsoft.PowerToys.STATestExtension;
using Microsoft.PowerToys.ThumbnailHandler.Gcode;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace GcodeThumbnailProviderUnitTests
{
[STATestClass]
public class GcodeThumbnailProviderTests
{
[TestMethod]
public void GetThumbnailValidStreamGcode()
{
// Act
var filePath = "HelperFiles/sample.gcode";
GcodeThumbnailProvider provider = new GcodeThumbnailProvider(filePath);
Bitmap bitmap = provider.GetThumbnail(256);
Assert.IsTrue(bitmap != null);
}
[TestMethod]
public void GetThumbnailInValidSizeGcode()
{
// Act
var filePath = "HelperFiles/sample.gcode";
GcodeThumbnailProvider provider = new GcodeThumbnailProvider(filePath);
Bitmap bitmap = provider.GetThumbnail(0);
Assert.IsTrue(bitmap == null);
}
[TestMethod]
public void GetThumbnailToBigGcode()
{
// Act
var filePath = "HelperFiles/sample.gcode";
GcodeThumbnailProvider provider = new GcodeThumbnailProvider(filePath);
Bitmap bitmap = provider.GetThumbnail(10001);
Assert.IsTrue(bitmap == null);
}
[TestMethod]
public void CheckNoGcodeEmptyStringShouldReturnNullBitmap()
{
using (var reader = new StringReader(string.Empty))
{
Bitmap thumbnail = GcodeThumbnailProvider.GetThumbnail(reader, 256);
Assert.IsTrue(thumbnail == null);
}
}
[TestMethod]
public void CheckNoGcodeNullStringShouldReturnNullBitmap()
{
Bitmap thumbnail = GcodeThumbnailProvider.GetThumbnail(null, 256);
Assert.IsTrue(thumbnail == null);
}
}
}