public void StoreAndPersistAnEntity()
        {
            var storeable = new InMemoryImplementation {
                Id = 1
            };

            _context.Setup(context => context.Data).Returns(new List <InMemoryImplementation>());

            _repository.Save(storeable);
            var actual = _repository.All();

            actual.Should().Contain(storeable);
        }
        private static List <InMemoryImplementation> BuildTestListOfStoreable(int start, int finish)
        {
            var storeables = new List <InMemoryImplementation>();

            for (var i = start; i < finish; i++)
            {
                var storeable = new InMemoryImplementation {
                    Id = i
                };
                storeables.Add(storeable);
            }

            return(storeables);
        }
        public void FindEntity()
        {
            const int entityId  = 1;
            var       storeable = new InMemoryImplementation {
                Id = entityId
            };
            var storeables = new List <InMemoryImplementation> {
                storeable
            };

            _context.Setup(context => context.Data).Returns(storeables);

            var actual = _repository.FindById(entityId);

            actual.Should().BeSameAs(storeable);
        }
        public void RemoveAnEntity()
        {
            const int entityId  = 1;
            var       storeable = new InMemoryImplementation {
                Id = entityId
            };
            var storeables = new List <InMemoryImplementation> {
                storeable
            };

            _context.Setup(context => context.Data).Returns(storeables);

            _repository.Delete(entityId);
            var actual = _repository.All();

            actual.Should().NotContain(storeable);
        }
        public void ProvideAllEntities()
        {
            var storeable = new InMemoryImplementation {
                Id = 1
            };
            var secondStoreable = new InMemoryImplementation {
                Id = 2
            };
            var storeables = new List <InMemoryImplementation> {
                storeable, secondStoreable
            };

            _context.Setup(context => context.Data).Returns(storeables);

            var actual = _repository.All();

            actual.Should().HaveCount(2);
        }
        public void NotStoreADuplicateEntity()
        {
            const int entityId  = 1;
            var       storeable = new InMemoryImplementation {
                Id = entityId
            };
            var duplicateStoreable = new InMemoryImplementation {
                Id = entityId
            };
            var storeables = new List <InMemoryImplementation> {
                storeable
            };

            _context.Setup(context => context.Data).Returns(storeables);

            _repository.Save(duplicateStoreable);
            var actual = _repository.All();

            actual.Should().NotContain(duplicateStoreable);
        }