Exemplo n.º 1
0
        public void Delete_ExistingEntity_DbEntryDeleted()
        {
            // arrange
            StubEntity newEntity = new StubEntity {
                Id = 1, Name = "test"
            };

            _repository.Add(newEntity);
            _repository.Delete(newEntity);

            //assert
            Assert.Null(_testDbContext.Set <StubEntity>().Find(newEntity.Id));
        }
Exemplo n.º 2
0
        public void Add_NeWEntity_DbEntryAdded()
        {
            // arrange
            StubEntity newEntity = new StubEntity {
                Id = 1, Name = "test"
            };

            // act
            _repository.Add(newEntity);

            // assert
            Assert.Equal("test", _testDbContext.Set <StubEntity>().Find(newEntity.Id).Name);
        }
Exemplo n.º 3
0
        public void Update_ExistingEntity_DbEntryUpdated()
        {
            // arrange
            StubEntity newEntity = new StubEntity {
                Id = 1, Name = "test"
            };

            _repository.Add(newEntity);
            _repository.Update(new StubEntity {
                Id = 1, Name = "edited"
            });

            //assert
            Assert.Equal("edited", _testDbContext.Set <StubEntity>().Find(newEntity.Id).Name);
        }