public void Delete_WithValidId_ExpectInvalidOperationException( string xmlDataFilename, int individualId, int applicationId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(individualId); entity.Id = applicationId; var classUnderTest = TestFixtureContext.CreateInstance(); // Act classUnderTest.Delete(entity); // Assert TestDelegate retrieve = () => TestFixtureContext.Retrieve <decimal>( "Principal", "Application", string.Format("[Id] = {0}", applicationId)); Assert.Throws <InvalidOperationException>(retrieve); }
public void Update_WhenLastNameIsChanged_ExpectProperLastName( string xmlDataFilename, string expectedLastName, int individualId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(); entity.Id = individualId; entity.LastName = expectedLastName; var classUnderTest = TestFixtureContext.CreateInstance(); // Act classUnderTest.Update(entity); // Assert var actual = TestFixtureContext.Retrieve <string>( "LastName", "Individual", string.Format("[Id] = {0}", individualId)); Assert.AreEqual(expectedLastName, actual); }
public void Update_WhenPrincipalIsChanged_ExpectProperPrincipal( string xmlDataFilename, int individualId, int applicationId, decimal expectedPrincipal) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(individualId); entity.Id = applicationId; entity.Principal = expectedPrincipal; var classUnderTest = TestFixtureContext.CreateInstance(); // Act classUnderTest.Update(entity); // Assert var actual = TestFixtureContext.Retrieve <decimal>( "Principal", "Application", string.Format("[Id] = {0}", applicationId)); Assert.AreEqual(expectedPrincipal, actual); }
public void Update_WhenHighSchoolNameIsChanged_ExpectProperHighSchoolName( string xmlDataFilename, string expectedHighSchoolName, int studentId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(studentId); entity.HighSchoolName = expectedHighSchoolName; var classUnderTest = TestFixtureContext.CreateInstance(); // Act classUnderTest.Update(entity); // Assert var actual = TestFixtureContext.Retrieve <string>( "HighSchoolName", "Student", string.Format("[Id] = {0}", studentId)); Assert.AreEqual(expectedHighSchoolName, actual); }
public void Create_WithNullEntity_ExpectArgumentNullException( string xmlDataFilename) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var classUnderTest = TestFixtureContext.CreateInstance(); // Act TestDelegate act = () => classUnderTest.Create(null); // Assert Assert.Throws <ArgumentNullException>(act); }
public void Retrieve_WithInvalidId_ExpectArgumentOutOfRangeException( string xmlDataFilename, int id) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var classUnderTest = TestFixtureContext.CreateInstance(); // Act TestDelegate act = () => classUnderTest.Retrieve(id); // Assert Assert.Throws <ArgumentOutOfRangeException>(act); }
public void Retrieve_WhenEntityWithIdNotStoredInDatabase_ExpectEntityIsNull( string xmlDataFilename, int id) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var classUnderTest = TestFixtureContext.CreateInstance(); // Act var actual = classUnderTest.Retrieve(id); // Assert Assert.IsNull(actual); }
public void Retrieve_WithValidId_ExpectEntityHavingIdIsRetrieved( string xmlDataFilename, int id) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var classUnderTest = TestFixtureContext.CreateInstance(); // Act var actual = classUnderTest.Retrieve(id); // Assert Assert.NotNull(actual); Assert.AreEqual(id, actual.Id); }
public void Create_WithInvalidStudentId_ExpectInvalidOperationException( string xmlDataFilename, int studentId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(studentId); var classUnderTest = TestFixtureContext.CreateInstance(); // Act TestDelegate act = () => classUnderTest.Create(entity); // Assert Assert.Throws <InvalidOperationException>(act); }
public void Create_WithValidIndividual_ExpectProperIdIsReturned( string xmlDataFilename, int expectedId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(); var classUnderTest = TestFixtureContext.CreateInstance(); // Act var actual = classUnderTest.Create(entity); // Assert Assert.AreEqual(expectedId, actual); }
public void Create_WithInvalidHighSchoolState_ExpectInvalidOperationException( string xmlDataFilename, int studentId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(studentId); entity.Principal = SqlMoney.MaxValue.ToDecimal(); var classUnderTest = TestFixtureContext.CreateInstance(); // Act TestDelegate act = () => classUnderTest.Create(entity); // Assert Assert.Throws <InvalidOperationException>(act); }
public void Delete_WithValidId_ExpectInvalidOperationException( string xmlDataFilename, int studentId) { // Arrange TestFixtureContext.SetupTestDatabase(xmlDataFilename); var entity = TestFixtureContext.CreateValidEntity(studentId); var classUnderTest = TestFixtureContext.CreateInstance(); // Act classUnderTest.Delete(entity); // Assert TestDelegate retrieve = () => TestFixtureContext.Retrieve <string>( "HighSchoolName", "Student", string.Format("[Id] = {0}", studentId)); Assert.Throws <InvalidOperationException>(retrieve); }