public void SaveIcon_SaveIcon_InDirectory() { //arrange string filepath = @"C:\Users\Artemman\Documents\Visual Studio 2013\Projects\ToolBar\ToolBar.Tests\TestContent\Новый текстовый документ.txt", directory = @".\Icons\Новый текстовый документ.txt.ico"; //act model.SaveIcon(filepath, directory); //assert Assert.IsTrue(File.Exists(directory)); }
private void Execute(object parametr) { IDataObject idata = parametr as IDataObject; if (idata != null) { string[] path = (string[])idata.GetData(DataFormats.FileDrop, true); if (path != null) { string directoryfile = @".\Icons\"; if (File.Exists(path[0])) { string filename = Path.GetFileName(path[0]); directoryfile += filename + ".ico"; _modelList.SaveIcon(path[0], directoryfile); ItemsCollection.Add(new Item { Path = path[0], Image = _modelList.GetBitmap(filename + ".ico"), Name = Path.GetFileNameWithoutExtension(path[0]) }); _xamlscriptgenerator.SaveData(datafile, path[0], filename + ".ico", Path.GetFileNameWithoutExtension(path[0])); } else if (Directory.Exists(path[0])) { string filename = new DirectoryInfo(path[0]).Name; directoryfile += filename + ".ico"; _modelList.SaveIcon(directoryfile, Properties.Resources.folder); ItemsCollection.Add(new Item { Path = path[0], Image = _modelList.GetBitmap(filename + ".ico"), Name = filename }); _xamlscriptgenerator.SaveData(datafile, path[0], filename + ".ico", filename); } } else { MessageBox.Show("Invalid operaiton. You can't add to the ToolBar: Desktop or Basket.", "Error!"); } } }