public void TestCommand()
        {
            _IWebServicesSettings = Substitute.For<IDiscogsAuthentificationProvider>();
            _Infra = Substitute.For<IInfraDependencies>();
            FileSystem fs = new FileSystem();
            _Infra.File.Returns(fs);

            _Target = new ExportKeyViewModel(_IWebServicesSettings, _Infra);
    
            ICommand com = _Target.Commit;
            com.MonitorEvents();

            com.Should().NotBeNull();
            com.CanExecute(null).Should().BeTrue();

            com.ShouldNotRaise("CanExecuteChanged");

            _Target.Directory = "24";

            com.CanExecute(null).Should().BeFalse();
            com.ShouldRaise("CanExecuteChanged");
   
            _Target.Directory = @"C:\";

            com.CanExecute(null).Should().BeTrue();
            com.ShouldRaise("CanExecuteChanged");
        }
 public void SetUp()
 {
     _IWindow = Substitute.For<IWindow>();
     _IWebServicesSettings = Substitute.For<IDiscogsAuthentificationProvider>();
     _Infra = Substitute.For<IInfraDependencies>();
     _Target = new ExportKeyViewModel(_IWebServicesSettings, _Infra) { Window = _IWindow };
 }
        public void Test_Commit_OK_2()
        {
            //IMusicSession ims = Substitute.For<IMusicSession>();
            //ims.Setting.WebUserSettings.Returns(_IWebServicesSettings);
            //ims.Dependencies.Returns(_Infra);

            _Target = new ExportKeyViewModel(_IWebServicesSettings, _Infra) { Window = _IWindow };

            _Infra.File.DirectoryExists(Arg.Any<string>()).Returns(true);
            var commit = _Target.Commit;

            _Target.Directory = "toto";
            _Target.Password = "******";

            Dictionary<string, string> d = new Dictionary<string, string>();
            _Infra.File.CreateNewAvailableName("toto", "MusicCollectionkeys", Arg.Any<string>(), true).Returns("mam23");
            _IWebServicesSettings.GetPrivateKeys().Returns(d);
            _Infra.Zip.ZippAsync(Arg.Any<IEnumerable<string>>(), "mam23", "asticot").Returns(Task.FromResult<bool>(true));
            commit.Execute(null);

            _IWindow.Received().Close();
            _Infra.File.Received().CreateNewAvailableName("toto", "MusicCollectionkeys", Arg.Any<string>(), true);
            _IWebServicesSettings.Received().GetPrivateKeys();
            _Infra.Zip.Received().ZippAsync(Arg.Any<IEnumerable<string>>(), "mam23", "asticot");
            _IWindow.Received().ShowMessage("Keys exported successfully to mam23!", "Exporting Discogs Key", false);
        }
 private void DoExportDiscogs()
 {
     var export = new ExportKeyViewModel(_IWebServicesSettingsWrapper, _IInfraDependencies);
     var exportwndow = this.Window.CreateFromViewModel(export);
     exportwndow.ShowDialog();
 }