public RecordAlteringOperationViewModel(ISafe safe, string recordId, IFileIdGenerator fileIdGenerator, Action reloadAction, Action closeAction) { _safe = safe; _recordId = recordId; _reloadAction = reloadAction; _closeAction = closeAction; var record = safe.GetRecord(recordId); Record = new RecordViewModel(record, safe, fileIdGenerator); SaveCommand = new DelegateCommand(Save, CanSave); DeleteCommand = new DelegateCommand(Delete); DiscardCommand = new DelegateCommand(Discard); GoToSearchCommand = new DelegateCommand(GoToSearch, () => !Record.IsRecordModified); Record.RecordChanged += () => { GoToSearchCommand.RaiseCanExecuteChanged(); }; Record.PropertyChanged += (a, b) => { SaveCommand.RaiseCanExecuteChanged(); }; }
public void SetUp() { _recordid = "RecordId"; _record = new Record() { Header = new RecordHeader() { Id = _recordid, Name = "RecordName", Tags = "Tag1;Tag2", }, PasswordRecords = new List <PasswordRecord>() { new PasswordRecord() { Name = "SomeName1", Value = "SomeValue1" }, }, FileRecords = new List <FileRecord>() { new FileRecord() { Name = "sss", Description = "ddd", Extention = "xyz", FileId = "ssss", AssociatedRecordId = _recordid }, }, }; _safe = Substitute.For <ISafe>(); var recordId = _record.Header.Id; _safe.GetRecord(recordId).Returns(_record); _recordAlteringOperationViewModel = new RecordAlteringOperationViewModel(_safe, recordId, new IdGenerator(), () => { _isReloadActionCalled = true; }, () => { _isCloseActionCalled = true; }); _saveCommandObserver = _recordAlteringOperationViewModel.SaveCommand.GetDelegateCommandObserver(); }