Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }