public void FileName_ShouldNOTUpdateValue_WhenNameIsInValid() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); string[] invalidNames = { string.Empty, " ", // no name. "%1", // single name value. "%7 (%5)", // name max index exceeded. "%8 (%8)", // name max index exceeded. "%5 (%3 )", // name contains extra spaces. "%5 (%3)", // name contains extra spaces. "%5 ( %3)", // name contains extra spaces. "% 5 ( %3)", // name contains extra spaces. "%5 (% 3)", // name contains extra spaces. "%5 ( %3 )", // name contains extra spaces. }; // act and Assert foreach (string invalidName in invalidNames) { viewModel = new ImageResizerViewModel(); viewModel.FileName = invalidName; Assert.AreNotEqual(invalidName, viewModel.FileName); ImageResizerSettings settings = SettingsUtils.GetSettings <ImageResizerSettings>(Module); Assert.AreNotEqual(invalidName, settings.Properties.ImageresizerFileName.Value); } }
public ImageResizerPage() { InitializeComponent(); ViewModel = new ImageResizerViewModel(ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; }
public ImageResizerPage() { InitializeComponent(); ViewModel = new ImageResizerViewModel(); DataContext = ViewModel; }
public ImageResizerPage() { InitializeComponent(); var settingsUtils = new SettingsUtils(); ViewModel = new ImageResizerViewModel(settingsUtils, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; }
public ImageResizerPage() { InitializeComponent(); var settingsUtils = new SettingsUtils(new SystemIOProvider()); ViewModel = new ImageResizerViewModel(settingsUtils, ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; }
public void JPEGQualityLevel_ShouldSetValueToTen_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); // act viewModel.JPEGQualityLevel = 10; // Assert viewModel = new ImageResizerViewModel(); Assert.AreEqual(10, viewModel.JPEGQualityLevel); }
public void PngInterlaceOption_ShouldSetValueToTen_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); // act viewModel.PngInterlaceOption = 10; // Assert viewModel = new ImageResizerViewModel(); Assert.AreEqual(10, viewModel.PngInterlaceOption); }
public void AddRow_ShouldAddEmptyImageSize_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); int sizeOfOriginalArray = viewModel.Sizes.Count; // act viewModel.AddRow(); // Assert Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray + 1); }
public void TiffCompressOption_ShouldSetValueToTen_WhenSuccefull() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); // act viewModel.TiffCompressOption = 10; // Assert viewModel = new ImageResizerViewModel(); Assert.AreEqual(10, viewModel.TiffCompressOption); }
public void FileName_ShouldUpdateValue_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); string expectedValue = "%1 (%3)"; // act viewModel.FileName = expectedValue; // Assert viewModel = new ImageResizerViewModel(); Assert.AreEqual(expectedValue, viewModel.FileName); }
public void Encoder_ShouldUpdateValue_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); // act viewModel.Encoder = 3; // Assert viewModel = new ImageResizerViewModel(); Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.GetEncoderGuid(viewModel.Encoder)); Assert.AreEqual(3, viewModel.Encoder); }
public void AddRow_ShouldAddEmptyImageSize_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); int sizeOfOriginalArray = viewModel.Sizes.Count; // act viewModel.AddRow(); // Assert Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray + 1); }
public void KeepDateModified_ShouldUpdateValue_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); // act viewModel.KeepDateModified = true; // Assert ImageResizerSettings settings = SettingsUtils.GetSettings <ImageResizerSettings>(Module); Assert.AreEqual(true, settings.Properties.ImageresizerKeepDateModified.Value); }
public void JPEGQualityLevel_ShouldSetValueToTen_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); // act viewModel.JPEGQualityLevel = 10; // Assert viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); Assert.AreEqual(10, viewModel.JPEGQualityLevel); }
public void PngInterlaceOption_ShouldSetValueToTen_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); // act viewModel.PngInterlaceOption = 10; // Assert viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); Assert.AreEqual(10, viewModel.PngInterlaceOption); }
public void Encoder_ShouldUpdateValue_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); // act viewModel.Encoder = 3; // Assert viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.GetEncoderGuid(viewModel.Encoder)); Assert.AreEqual(3, viewModel.Encoder); }
public void AddRow_ShouldAddEmptyImageSize_WhenSuccessful() { // arrange var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils(); Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SendMockIPCConfigMSG); int sizeOfOriginalArray = viewModel.Sizes.Count; // act viewModel.AddRow(); // Assert Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray + 1); }
public void KeepDateModified_ShouldUpdateValue_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); // act viewModel.KeepDateModified = true; // Assert ImageResizerSettings settings = SettingsUtils.GetSettings <ImageResizerSettings>(Module); Assert.AreEqual(true, settings.Properties.ImageresizerKeepDateModified.Value); }
public void FileName_ShouldUpdateValue_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); string expectedValue = "%1 (%3)"; // act viewModel.FileName = expectedValue; // Assert viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); Assert.AreEqual(expectedValue, viewModel.FileName); }
public void DeleteImageSize_ShouldDeleteImageSize_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); int sizeOfOriginalArray = viewModel.Sizes.Count; ImageSize deleteCandidate = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First(); // act viewModel.DeleteImageSize(0); // Assert Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray - 1); Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate)); }
public void TiffCompressOptionShouldSetValueToTenWhenSuccessful() { // arrange var fileSystemMock = new MockFileSystem(); var mockSettingsUtils = new SettingsUtils(fileSystemMock); Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG); // act viewModel.TiffCompressOption = 10; // Assert viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG); Assert.AreEqual(10, viewModel.TiffCompressOption); }
public void DeleteImageSize_ShouldDeleteImageSize_WhenSuccessful() { // arrange Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG); int sizeOfOriginalArray = viewModel.Sizes.Count; ImageSize deleteCandidate = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First(); // act viewModel.DeleteImageSize(0); // Assert Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray - 1); Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate)); }
public void IsEnabled_ShouldEnableModule_WhenSuccessful() { // arrange ImageResizerViewModel viewModel = new ImageResizerViewModel(); // Assert ShellPage.DefaultSndMSGCallback = msg => { OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg); Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer); }; // act viewModel.IsEnabled = true; }
public void TiffCompressOption_ShouldSetValueToTen_WhenSuccessful() { // arrange var mockIOProvider = IIOProviderMocks.GetMockIOProviderForSaveLoadExists(); var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object); Func <string, int> SendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SendMockIPCConfigMSG); // act viewModel.TiffCompressOption = 10; // Assert viewModel = new ImageResizerViewModel(mockSettingsUtils, SendMockIPCConfigMSG); Assert.AreEqual(10, viewModel.TiffCompressOption); }
public void JPEGQualityLevelShouldSetValueToTenWhenSuccessful() { // arrange var fileSystemMock = new MockFileSystem(); var mockSettingsUtils = new SettingsUtils(fileSystemMock); Func <string, int> sendMockIPCConfigMSG = msg => { return(0); }; ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name); // act viewModel.JPEGQualityLevel = 10; // Assert viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name); Assert.AreEqual(10, viewModel.JPEGQualityLevel); }