public void Retrieve_WithScenarioDataInDatabase_ExpectEnityIsNull(
            int id)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            // Act
            var actual = classUnderTest.Retrieve(id);

            // Assert
            Assert.Null(actual);
        }
        public void Retrieve_WithScenarioDataInDatabase_ExpectProperLastName(
            int id,
            string expectedLastName)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            // Act
            var actual = classUnderTest.Retrieve(id);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedLastName, actual.LastName);
        }
        public void Create_WithScenarioDataInDatabase_ExpectProperNextIdIsGenerated(
            int expectedId)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            var entity = 
                new IndividualEntity
                             {
                                 LastName = "Jones",
                                 FirstName = "Wilma",
                                 MiddleName = "Vanessa",
                                 DateOfBirth = new DateTime(1993, 11, 17),
                             };

            // Act
            var actual = classUnderTest.Create(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedId, actual);
        }
        public void Update_WithScenarioDataInDatabaseAndLastNameIsInvalid_ExpectSqlException(
            int id)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            var entity = classUnderTest.Retrieve(id);
            Assert.NotNull(entity);

            entity.LastName = null;

            // Act
            classUnderTest.Update(entity);

            // Assert
            Assert.Fail("Expected an exception");
        }
        public void Update_WithScenarioDataInDatabase_ExpectLastNameIsChanged(
            int id,
            string expectedLastname)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            var entity = classUnderTest.Retrieve(id);
            Assert.NotNull(entity);

            entity.LastName = expectedLastname;

            // Act
            classUnderTest.Update(entity);

            // Assert
            var result = classUnderTest.Retrieve(id);
            Assert.NotNull(result);
            Assert.AreEqual(expectedLastname, result.LastName);
        }
        public void Delete_WithScenarioDataInDatabase_ExpectInvalidOperationException(
            int id)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            var entity =
                new IndividualEntity
                {
                    Id = id,
                };

            // Act
            classUnderTest.Delete(entity);

            // Assert
            Assert.Fail("Expected an exception");
        }
        public void Delete_WithScenarioDataInDatabase_ExpectEntityIsRemoved(
            int id)
        {
            // Arrange
            var classUnderTest = new IndividualDal(ConnectionString);

            var entity = classUnderTest.Retrieve(id);
            Assert.NotNull(entity);

            // Act
            classUnderTest.Delete(entity);

            // Assert
            var result = classUnderTest.Retrieve(id);
            Assert.IsNull(result);
        }