Beispiel #1
0
        public void Delete_NonexistentHero_PreservesNumberOfRecords()
        {
            // Arrange
            var numPreExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            // Act
            Adapter.Delete(Guid.NewGuid());

            // Assert
            var numPostExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            Assert.AreEqual(numPreExistingHeroes, numPostExistingHeroes);
        }
Beispiel #2
0
        public void Save_NewHero_InsertsOneRecord()
        {
            // Arrange
            var numPreExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);
            var newHero = new Hero(Guid.NewGuid(), "Hawkeye", "???", new List <Power>());

            // Act
            Adapter.Save(newHero);

            // Assert
            var numPostExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            Assert.AreEqual(numPreExistingHeroes + 1, numPostExistingHeroes);
        }
Beispiel #3
0
        public void Delete_ExistingHero_RemovesOneRecord()
        {
            // Arrange

            // make sure at least one hero exists, so we can delete it
            var hero = new Hero(Guid.NewGuid(), "Batman", "Gotham", new List <Power>());

            Adapter.Save(hero);
            var numPreExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            // Act
            Adapter.Delete(hero.Id);

            // Assert
            var numPostExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            Assert.AreEqual(numPreExistingHeroes - 1, numPostExistingHeroes);
        }
Beispiel #4
0
        public void Save_ExistingHero_PreservesNumberOfRecords()
        {
            // Arrange

            // make sure at least one hero exists, so we have something to update
            var oldHero = new Hero(Guid.NewGuid(), "Superman", "Metropolis", new List <Power>());

            Adapter.Save(oldHero);
            var numPreExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            // Act
            var newHero = new Hero(oldHero.Id, "Superman Red Son", "Moscow", new List <Power>());

            Adapter.Save(newHero);

            // Assert
            var numPostExistingHeroes = AdapterTestHelpers.CountRedisHeroes(ConnectionString);

            Assert.AreEqual(numPreExistingHeroes, numPostExistingHeroes);
        }