public void ObservableRepository_gets_ViewModel_of_Model() { // ARRANGE var model = new Tag(); var repository = this.mocks.Create <ITagRepository>(); repository .Setup(r => r.FindAll()) .Returns(model.Yield()); var observableRepository = new RepositoryViewModel <TagViewModel, Tag>(repository.Object, m => new TagViewModel(m)); observableRepository.FillAll(); // ACT var result = observableRepository.GetViewModel(new Tag { Id = model.Id }); // ASSERT Assert.Same(observableRepository.Single(), result); }
public void ObservableRepository_getting_unknown_ViewModel_throws() { // ARRANGE var model = new Tag(); var repository = this.mocks.Create <ITagRepository>(); repository .Setup(r => r.FindAll()) .Returns(model.Yield()); var observableRepository = new RepositoryViewModel <TagViewModel, Tag>(repository.Object, m => new TagViewModel(m)); observableRepository.FillAll(); // ACT Assert.Throws <InvalidOperationException>(() => observableRepository.GetViewModel(new Tag { Id = Guid.NewGuid() })); }