2020-08-18 13:43:58 -07:00
|
|
|
|
// 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;
|
2020-11-02 18:33:43 +01:00
|
|
|
|
using System.IO.Abstractions.TestingHelpers;
|
2020-08-18 13:43:58 -07:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text.Json;
|
2020-10-22 09:45:48 -07:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
2020-10-08 16:34:19 -07:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
2020-09-21 10:14:44 -07:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
2020-08-18 13:43:58 -07:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2020-09-21 10:14:44 -07:00
|
|
|
|
using Moq;
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
namespace ViewModelTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestClass]
|
|
|
|
|
|
public class ImageResizer
|
|
|
|
|
|
{
|
2020-11-02 18:33:43 +01:00
|
|
|
|
private Mock<ISettingsUtils> _mockGeneralSettingsUtils;
|
2020-09-23 13:20:32 -07:00
|
|
|
|
|
2020-11-02 18:33:43 +01:00
|
|
|
|
private Mock<ISettingsUtils> _mockImgResizerSettingsUtils;
|
2020-09-23 13:20:32 -07:00
|
|
|
|
|
|
|
|
|
|
[TestInitialize]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void SetUpStubSettingUtils()
|
2020-09-23 13:20:32 -07:00
|
|
|
|
{
|
2020-11-02 18:33:43 +01:00
|
|
|
|
_mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
|
|
|
|
|
_mockImgResizerSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
2020-09-23 13:20:32 -07:00
|
|
|
|
}
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
2020-10-08 16:34:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Test if the original settings files were modified.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
|
[DataRow("v0.18.2", "settings.json")]
|
|
|
|
|
|
[DataRow("v0.19.2", "settings.json")]
|
|
|
|
|
|
[DataRow("v0.20.1", "settings.json")]
|
|
|
|
|
|
[DataRow("v0.21.1", "settings.json")]
|
|
|
|
|
|
[DataRow("v0.22.0", "settings.json")]
|
|
|
|
|
|
public void OriginalFilesModificationTest(string version, string fileName)
|
|
|
|
|
|
{
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var settingPathMock = new Mock<ISettingsPath>();
|
|
|
|
|
|
|
|
|
|
|
|
var fileMock = BackCompatTestProperties.GetModuleIOProvider(version, ImageResizerSettings.ModuleName, fileName);
|
|
|
|
|
|
var mockSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object);
|
|
|
|
|
|
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<ImageResizerSettings>(ImageResizerSettings.ModuleName);
|
2020-10-08 16:34:19 -07:00
|
|
|
|
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var mockGeneralFileMock = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
|
|
|
|
|
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralFileMock.Object, settingPathMock.Object);
|
2021-01-14 14:14:29 +02:00
|
|
|
|
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
2020-11-02 18:33:43 +01:00
|
|
|
|
|
2020-10-08 16:34:19 -07:00
|
|
|
|
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
|
|
|
|
|
|
|
|
|
|
|
// Initialise View Model with test Config files
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, generalSettingsRepository, sendMockIPCConfigMSG, (string name) => name);
|
2020-10-08 16:34:19 -07:00
|
|
|
|
|
2020-10-30 14:42:49 -04:00
|
|
|
|
// Verify that the old settings persisted
|
2020-10-08 16:34:19 -07:00
|
|
|
|
Assert.AreEqual(originalGeneralSettings.Enabled.ImageResizer, viewModel.IsEnabled);
|
2020-10-09 17:58:52 -07:00
|
|
|
|
Assert.AreEqual(ImageResizerViewModel.GetEncoderIndex(originalSettings.Properties.ImageresizerFallbackEncoder.Value), viewModel.Encoder);
|
2020-10-08 16:34:19 -07:00
|
|
|
|
Assert.AreEqual(originalSettings.Properties.ImageresizerFileName.Value, viewModel.FileName);
|
|
|
|
|
|
Assert.AreEqual(originalSettings.Properties.ImageresizerJpegQualityLevel.Value, viewModel.JPEGQualityLevel);
|
|
|
|
|
|
Assert.AreEqual(originalSettings.Properties.ImageresizerKeepDateModified.Value, viewModel.KeepDateModified);
|
|
|
|
|
|
Assert.AreEqual(originalSettings.Properties.ImageresizerPngInterlaceOption.Value, viewModel.PngInterlaceOption);
|
|
|
|
|
|
Assert.AreEqual(originalSettings.Properties.ImageresizerSizes.Value.Count, viewModel.Sizes.Count);
|
|
|
|
|
|
Assert.AreEqual(originalSettings.Properties.ImageresizerTiffCompressOption.Value, viewModel.TiffCompressOption);
|
|
|
|
|
|
|
2020-11-17 15:29:21 -08:00
|
|
|
|
// Verify that the stub file was used
|
|
|
|
|
|
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
2020-11-02 18:33:43 +01:00
|
|
|
|
BackCompatTestProperties.VerifyModuleIOProviderWasRead(fileMock, ImageResizerSettings.ModuleName, expectedCallCount);
|
|
|
|
|
|
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralFileMock, expectedCallCount);
|
2020-10-08 16:34:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-18 13:43:58 -07:00
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void IsEnabledShouldEnableModuleWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Assert
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg =>
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
|
|
|
|
|
Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// arrange
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(_mockImgResizerSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.IsEnabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void JPEGQualityLevelShouldSetValueToTenWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var fileSystemMock = new MockFileSystem();
|
|
|
|
|
|
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.JPEGQualityLevel = 10;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2021-01-14 14:14:29 +02:00
|
|
|
|
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
Assert.AreEqual(10, viewModel.JPEGQualityLevel);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void PngInterlaceOptionShouldSetValueToTenWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var fileSystemMock = new MockFileSystem();
|
|
|
|
|
|
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.PngInterlaceOption = 10;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2021-01-14 14:14:29 +02:00
|
|
|
|
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
Assert.AreEqual(10, viewModel.PngInterlaceOption);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void TiffCompressOptionShouldSetValueToTenWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var fileSystemMock = new MockFileSystem();
|
|
|
|
|
|
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.TiffCompressOption = 10;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2021-01-14 14:14:29 +02:00
|
|
|
|
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
Assert.AreEqual(10, viewModel.TiffCompressOption);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void FileNameShouldUpdateValueWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var fileSystemMock = new MockFileSystem();
|
|
|
|
|
|
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
string expectedValue = "%1 (%3)";
|
|
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.FileName = expectedValue;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2021-01-14 14:14:29 +02:00
|
|
|
|
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
Assert.AreEqual(expectedValue, viewModel.FileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void KeepDateModifiedShouldUpdateValueWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-09-23 13:20:32 -07:00
|
|
|
|
var settingUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
2020-09-21 10:14:44 -07:00
|
|
|
|
|
|
|
|
|
|
var expectedSettingsString = new ImageResizerSettings() { Properties = new ImageResizerProperties() { ImageresizerKeepDateModified = new BoolProperty() { Value = true } } }.ToJsonString();
|
2020-11-17 15:29:21 -08:00
|
|
|
|
|
2020-10-30 16:43:09 -07:00
|
|
|
|
// Using Ordinal since this is used internally
|
2020-09-21 10:14:44 -07:00
|
|
|
|
settingUtils.Setup(x => x.SaveSettings(
|
|
|
|
|
|
It.Is<string>(content => content.Equals(expectedSettingsString, StringComparison.Ordinal)),
|
2020-10-08 16:34:19 -07:00
|
|
|
|
It.Is<string>(module => module.Equals(ImageResizerSettings.ModuleName, StringComparison.Ordinal)),
|
2020-09-21 10:14:44 -07:00
|
|
|
|
It.IsAny<string>()))
|
|
|
|
|
|
.Verifiable();
|
|
|
|
|
|
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(settingUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.KeepDateModified = true;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2020-09-21 10:14:44 -07:00
|
|
|
|
settingUtils.Verify();
|
2020-08-18 13:43:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void EncoderShouldUpdateValueWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-11-02 18:33:43 +01:00
|
|
|
|
var fileSystemMock = new MockFileSystem();
|
|
|
|
|
|
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.Encoder = 3;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2021-01-14 14:14:29 +02:00
|
|
|
|
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-10-09 17:58:52 -07:00
|
|
|
|
Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.EncoderGuid);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
Assert.AreEqual(3, viewModel.Encoder);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void AddRowShouldAddEmptyImageSizeWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-09-23 13:20:32 -07:00
|
|
|
|
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
int sizeOfOriginalArray = viewModel.Sizes.Count;
|
|
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.AddRow();
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2020-10-07 22:12:59 +02:00
|
|
|
|
Assert.AreEqual(sizeOfOriginalArray + 1, viewModel.Sizes.Count);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-06 15:00:25 -07:00
|
|
|
|
public void DeleteImageSizeShouldDeleteImageSizeWhenSuccessful()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
2020-09-23 13:20:32 -07:00
|
|
|
|
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
2020-11-17 15:29:21 -08:00
|
|
|
|
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
2021-01-14 14:14:29 +02:00
|
|
|
|
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
|
|
|
|
|
viewModel.AddRow();
|
2020-08-18 13:43:58 -07:00
|
|
|
|
int sizeOfOriginalArray = viewModel.Sizes.Count;
|
|
|
|
|
|
ImageSize deleteCandidate = viewModel.Sizes.Where<ImageSize>(x => x.Id == 0).First();
|
|
|
|
|
|
|
|
|
|
|
|
// act
|
|
|
|
|
|
viewModel.DeleteImageSize(0);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2020-10-07 22:12:59 +02:00
|
|
|
|
Assert.AreEqual(sizeOfOriginalArray - 1, viewModel.Sizes.Count);
|
2020-08-18 13:43:58 -07:00
|
|
|
|
Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-10-30 14:42:41 -04:00
|
|
|
|
public void UpdateWidthAndHeightShouldUpdateSizeWhenCorrectValuesAreProvided()
|
2020-08-18 13:43:58 -07:00
|
|
|
|
{
|
|
|
|
|
|
// arrange
|
|
|
|
|
|
ImageSize imageSize = new ImageSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = 0,
|
|
|
|
|
|
Name = "Test",
|
|
|
|
|
|
Fit = (int)ResizeFit.Fit,
|
|
|
|
|
|
Width = 30,
|
|
|
|
|
|
Height = 30,
|
|
|
|
|
|
Unit = (int)ResizeUnit.Pixel,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
double negativeWidth = -2.0;
|
|
|
|
|
|
double negativeHeight = -2.0;
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
imageSize.Width = negativeWidth;
|
|
|
|
|
|
imageSize.Height = negativeHeight;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
Assert.AreEqual(0, imageSize.Width);
|
|
|
|
|
|
Assert.AreEqual(0, imageSize.Height);
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
imageSize.Width = 50;
|
|
|
|
|
|
imageSize.Height = 50;
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
Assert.AreEqual(50, imageSize.Width);
|
|
|
|
|
|
Assert.AreEqual(50, imageSize.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|