예제 #1
0
        public void ObservableRepository_deletes_removed_items()
        {
            // ARRANGE

            var model      = new Tag();
            var repository = this.mocks.Create <ITagRepository>();

            repository
            .Setup(r => r.Upsert(model))
            .Returns(model);
            repository
            .Setup(r => r.Delete(model.Id))
            .Returns(true);

            var observableRepository = new RepositoryViewModel <TagViewModel, Tag>(repository.Object, m => new TagViewModel(m));
            var viewModel            = new TagViewModel(model);

            observableRepository.Add(viewModel);

            // ACT

            observableRepository.Remove(viewModel);

            // ASSERT

            Assert.Empty(observableRepository);
        }
예제 #2
0
        public void ObservableRepository_upserts_added_items()
        {
            // ARRANGE

            var model      = new Tag();
            var repository = this.mocks.Create <ITagRepository>();

            repository
            .Setup(r => r.Upsert(model))
            .Returns(model);

            var observableRepository = new RepositoryViewModel <TagViewModel, Tag>(repository.Object, m => new TagViewModel(m));

            // ACT

            observableRepository.Add(new TagViewModel(model));

            // ASSERT

            Assert.Equal(model, observableRepository.Single().Model);
        }