public void Given1Printer_WhenSave_ThenAllPrintersRemovedFromConfig()
        {
            // Arrange
            var windowsStoragePathService = new WindowsStoragePathService();
            var mockFileIOService         = new Mock <IFileIOService>();

            mockFileIOService.Setup(x => x.Exists(
                                        It.IsAny <string>()))
            .Returns(true);

            mockFileIOService.Setup(x => x.ReadAllText(
                                        It.IsAny <string>()))
            .Returns("{\"Printers\":[{}]}");

            var sut = new PrinterConfigurationManagerService(
                windowsStoragePathService,
                mockFileIOService.Object);

            sut.Load();

            // Act
            sut.Save();

            // Assert
            var configJson = JsonConvert.SerializeObject(sut.Config);

            mockFileIOService.Verify(x => x.WriteAllText(
                                         It.Is <string>(x => x == windowsStoragePathService.UserAppConfigPrinterConfigurationsFilePath),
                                         It.Is <string>(x => x == configJson)), Times.Once);
        }
        public void GivenCurrentUser_WhenUserAppConfigPrinterConfigurationsFilePath_ThenCorrectPathReturned()
        {
            // Arrange
            var sut = new WindowsStoragePathService();

            // Act
            var path = sut.UserAppConfigPrinterConfigurationsFilePath;

            // Assert
            Assert.Equal($"C:\\Users\\{Environment.UserName}\\AppData\\Local\\MarlinToolset\\Config\\printers.json", path);
        }
        public void GivenCurrentUser_WhenUserAppDataPath_ThenCorrectPathReturned()
        {
            // Arrange
            var sut = new WindowsStoragePathService();

            // Act
            var path = sut.UserAppDataPath;

            // Assert
            Assert.Equal($"C:\\Users\\{Environment.UserName}\\AppData\\Local", path);
        }
        public void GivenCurrentUser_WhenSystemAppDataPath_ThenCorrectPathReturned()
        {
            // Arrange
            var sut = new WindowsStoragePathService();

            // Act
            var path = sut.SystemAppDataPath;

            // Assert
            Assert.Equal($"C:\\ProgramData", path);
        }
        public void GivenConfigNotExists_WhenLoad_ThenNoPrintersAreLoaded()
        {
            // Arrange
            var windowsStoragePathService = new WindowsStoragePathService();
            var mockFileIOService         = new Mock <IFileIOService>();

            mockFileIOService.Setup(x => x.Exists(
                                        It.IsAny <string>()))
            .Returns(false);

            var sut = new PrinterConfigurationManagerService(
                windowsStoragePathService,
                mockFileIOService.Object);

            sut.Load();

            // Act
            var result = sut.Load();

            // Assert
            Assert.False(result);
        }