Example #1
0
        public void InMemoryRepository_Save_AddsNewItem()
        {
            _repository = new InMemoryRepository <StoreableEntity>();

            var itemToBeSaved = new StoreableEntity()
            {
                Id = 1, Name = "ItemToBeSaved"
            };

            _repository.Save(itemToBeSaved);

            _result = _repository.All();
            Assert.IsTrue(((IEnumerable <StoreableEntity>)_result).Contains(itemToBeSaved));
        }
Example #2
0
        public void InMemoryRepository_Save_UpdatesExistingItem()
        {
            _repository = new InMemoryRepository <StoreableEntity>();
            var itemToBeSaved = new StoreableEntity()
            {
                Id = 1, Name = "ItemToBeSaved"
            };

            _repository.Save(itemToBeSaved);

            _repository.Save(itemToBeSaved);

            _result = _repository.All();
            Assert.IsTrue(((IEnumerable <StoreableEntity>)_result).All(c => c == itemToBeSaved));
        }
Example #3
0
        public void InMemoryRepository_Delete_RemovesExistingItem()
        {
            _repository = new InMemoryRepository <StoreableEntity>();
            var itemToBeSaved = new StoreableEntity()
            {
                Id = 1, Name = "ItemToBeSaved"
            };

            _repository.Save(itemToBeSaved);

            _repository.Delete(itemToBeSaved.Id);

            _result = _repository.All();
            Assert.IsFalse(((IEnumerable <StoreableEntity>)_result).Contains(itemToBeSaved));
        }
Example #4
0
        public void InMemoryRepository_FindById_ReturnsCorrectItem()
        {
            _repository = new InMemoryRepository <StoreableEntity>();

            var firstItem = new StoreableEntity()
            {
                Id = 1, Name = "firstItem"
            };

            _repository.Save(firstItem);

            var secondItem = new StoreableEntity()
            {
                Id = 2, Name = "SecondItem"
            };

            _repository.Save(secondItem);

            _result = _repository.FindById(1);

            Assert.AreEqual(firstItem, _result);
        }