public PasswordListViewModel( IPasswordManagerStorage storage, PasswordEditorViewModelFactory editorFactory, PasswordListEntryViewModel.Factory entryFactory ) { _storage = storage; _editorFactory = editorFactory; _entryFactory = entryFactory; _openEditorCommand = new RelayCommand( ( ) => OpenNewEditorInternal( null ) ); UpdateList( ); EnforceAtLeastOneEditor( ); }
public void ViewModelPresentsDatesFormattedByFuzzyDateFormatter( ) { // Set up TimeProvider.Now = new DateTime( 2011, 11, 14, 8, 0, 0 ); PasswordDigestDocument password = new PasswordDigestDocumentBuilder { Key = "ABCD", Iteration = 2, PasswordGenerator = PasswordGenerators.LegacyFull, CreatedOn = new DateTime( 2011, 11, 11 ), ModifiedOn = new DateTime( 2011, 11, 14 ), Note = "Need this for EFGH" }; // Exercise var viewModel = new PasswordListEntryViewModel( password, GuidToColor, FuzzyDateFormatter ); // Verify Assert.That( viewModel.CreationDate, Is.EqualTo( FuzzyDateFormatter.Format( new DateTime( 2011, 11, 11 ) ) ) ); Assert.That( viewModel.ModificationDate, Is.EqualTo( FuzzyDateFormatter.Format( new DateTime( 2011, 11, 14 ) ) ) ); }
public void EntryPresentsTextFromDocument( ) { // Set up PasswordDigestDocument password = new PasswordDigestDocumentBuilder { Key = "ABCD", Iteration = 2, PasswordGenerator = PasswordGenerators.LegacyFull, CreatedOn = new DateTime( 2011, 11, 11 ), ModifiedOn = new DateTime( 2011, 11, 14 ), Note = "Need this for EFGH" }; // Exercise var viewModel = new PasswordListEntryViewModel( password, GuidToColor, FuzzyDateFormatter ); // Verify Assert.That( viewModel.Name, Is.EqualTo( "ABCD" ) ); Assert.That( viewModel.Note, Is.EqualTo( "Need this for EFGH" ) ); }
public void ViewModelPresentsGeneratorUsingResources( ) { // Set up PasswordDigestDocument password = new PasswordDigestDocumentBuilder { Key = "ABCD", Iteration = 2, PasswordGenerator = PasswordGenerators.LegacyFull, CreatedOn = new DateTime( 2011, 11, 11 ), ModifiedOn = new DateTime( 2011, 11, 14 ), Note = "Need this for EFGH" }; // Exercise var viewModel = new PasswordListEntryViewModel( password, GuidToColor, FuzzyDateFormatter ); // Verify Assert.That( viewModel.GeneratorNameAndIteration, Is.EqualTo( Resources.PasswordGeneratorccf1451c4b3045a499b0d54ec3c3a7ee + " (2)" ) ); }
public void NoteIsNotVisibleWhenEmpty( ) { // Set up PasswordDigestDocument password = new PasswordDigestDocumentBuilder { Key = "ABCD", Iteration = 2, PasswordGenerator = PasswordGenerators.LegacyFull, CreatedOn = new DateTime( 2011, 11, 11 ), ModifiedOn = new DateTime( 2011, 11, 14 ), Note = "" }; // Exercise var viewModel = new PasswordListEntryViewModel( password, GuidToColor, FuzzyDateFormatter ); // Verify Assert.That( viewModel.NoteVisible, Is.False ); }
public void ViewModelPresentsMasterPasswordId( ) { // Set up Guid guid = Guid.Parse( "ADB07A84-ED76-420F-9570-D0684DD044FE" ); PasswordDigestDocument password = new PasswordDigestDocumentBuilder { Key = "ABCD", Iteration = 2, PasswordGenerator = PasswordGenerators.LegacyFull, CreatedOn = new DateTime( 2011, 11, 11 ), ModifiedOn = new DateTime( 2011, 11, 14 ), Note = "Need this for EFGH", MasterPasswordId = guid }; // Exercise var viewModel = new PasswordListEntryViewModel( password, GuidToColor, FuzzyDateFormatter ); // Verify Assert.That( viewModel.MasterPasswordGuid, Is.EqualTo( guid ) ); Assert.That( viewModel.MasterPasswordColor, Is.EqualTo( GuidToColor.Convert( guid ) ) ); }
public void OpenNewEditor( PasswordListEntryViewModel passwordListEntry ) { if ( passwordListEntry != null ) OpenNewEditorInternal( passwordListEntry.PasswordDocument ); }
private bool IsItemVisible( PasswordListEntryViewModel item ) { return string.IsNullOrWhiteSpace( _filterString ) || item.Name.Contains( _filterString ); }