Пример #1
0
        public void Delete_NonexistentPower_PreservesNumberOfRecords()
        {
            // Arrange
            var numPreExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

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

            // Assert
            var numPostExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

            Assert.AreEqual(numPreExistingPowers, numPostExistingPowers);
        }
Пример #2
0
        public void Save_NewPower_InsertsOneRecord()
        {
            // Arrange
            var numPreExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);
            var newPower             = new Power(Guid.NewGuid(), "Super Archery");

            // Act
            Adapter.Save(newPower);

            // Assert
            var numPostExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

            Assert.AreEqual(numPreExistingPowers + 1, numPostExistingPowers);
        }
Пример #3
0
        public void Delete_ExistingPower_RemovesOneRecord()
        {
            // Arrange

            // make sure at least one power exists, so we can delete it
            var power = new Power(Guid.NewGuid(), "Some ridiculous Silver Age stuff");

            Adapter.Save(power);
            var numPreExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

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

            // Assert
            var numPostExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

            Assert.AreEqual(numPreExistingPowers - 1, numPostExistingPowers);
        }
Пример #4
0
        public void Save_ExistingPower_PreservesNumberOfRecords()
        {
            // Arrange

            // make sure at least one power exists, so we have something to update
            var oldPower = new Power(Guid.NewGuid(), "Flight");

            Adapter.Save(oldPower);
            var numPreExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

            // Act
            var newPower = new Power(oldPower.Id, "SUUUUPER FLIGHT");

            Adapter.Save(newPower);

            // Assert
            var numPostExistingPowers = AdapterTestHelpers.CountSqlPowers(ConnectionString);

            Assert.AreEqual(numPreExistingPowers, numPostExistingPowers);
        }