예제 #1
0
        public void NameOfNewImageSizesIsIncrementedCorrectly()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.AddRow("New size"); // Add: "New size 1"
            viewModel.AddRow("New size"); // Add: "New size 2"
            viewModel.AddRow("New size"); // Add: "New size 3"
            viewModel.DeleteImageSize(1); // Delete: "New size 2"
            viewModel.AddRow("New size"); // Add: "New Size 4"

            // Assert
            Assert.AreEqual(viewModel.Sizes[0].Name, "New size 1");
            Assert.AreEqual(viewModel.Sizes[1].Name, "New size 3");
            Assert.AreEqual(viewModel.Sizes[2].Name, "New size 4");
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public void AddRowShouldAddEmptyImageSizeWhenSuccessful()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            int sizeOfOriginalArray = viewModel.Sizes.Count;

            // act
            viewModel.AddRow();

            // Assert
            Assert.AreEqual(sizeOfOriginalArray + 1, viewModel.Sizes.Count);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public void DeleteImageSizeShouldDeleteImageSizeWhenSuccessful()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            viewModel.AddRow();
            int       sizeOfOriginalArray = viewModel.Sizes.Count;
            ImageSize deleteCandidate     = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            // act
            viewModel.DeleteImageSize(0);

            // Assert
            Assert.AreEqual(sizeOfOriginalArray - 1, viewModel.Sizes.Count);
            Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
        }
예제 #7
0
        public void NewlyAddedImageSizeHasCorrectValues()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.AddRow("New size");

            // Assert
            ImageSize newTestSize = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            Assert.AreEqual(newTestSize.Name, "New size 1");
            Assert.AreEqual(newTestSize.Fit, (int)ResizeFit.Fit);
            Assert.AreEqual(newTestSize.Width, 854);
            Assert.AreEqual(newTestSize.Height, 480);
            Assert.AreEqual(newTestSize.Unit, (int)ResizeUnit.Pixel);
        }