public void EventRaised() { var directory = GetMethodSpecificWorkingDirectory(); PFW.CSIST203.Project3.Persisters.Access.AccessPersister obj = null; var tmpAccessDatabaseFile = System.IO.Path.Combine(directory, "sample-data.accdb"); CopyEmbeddedResourceBaseToDirectory("PFW.CSIST203.Project3.Tests.Resources.Data", directory); Assert.IsTrue(System.IO.File.Exists(tmpAccessDatabaseFile), "The sample data access database file was not found"); CreateTemporaryForm(form => { form.persister = new Project3.Persisters.Access.AccessPersister(tmpAccessDatabaseFile); form.txtRow.Text = "5"; // artificially set the selected row to 5 in the excel file AssertDelegateSuccess(() => form.btnPrevious.PerformClick(), "Failure when clicking the button"); // retrieve the data row from the persister var row = form.persister.GetRow(4); // Verify the data points displayed are in fact consistent with the row in question Assert.AreEqual(row["First Name"], form.txtFirstname.Text, "The displayed first name is not correct"); Assert.AreEqual(row["Last Name"], form.txtFirstname.Text, "The displayed last name is not correct"); Assert.AreEqual(row["E-mail Address"], form.txtFirstname.Text, "The displayed email is not correct"); Assert.AreEqual(row["Business Phone"], form.txtFirstname.Text, "The displayed business phone is not correct"); Assert.AreEqual(row["Company"], form.txtFirstname.Text, "The displayed company is not correct"); Assert.AreEqual(row["Job Title"], form.txtFirstname.Text, "The displayed job title is not correct"); }); }
/// <summary> /// Refactored method for creating a persister that uses the parameterless constructor /// </summary> /// <returns>A persister that should contain no data</returns> protected PFW.CSIST203.Project3.Persisters.Access.AccessPersister CreatePersister() { PFW.CSIST203.Project3.Persisters.Access.AccessPersister obj = null; AssertDelegateSuccess(() => { obj = new Project3.Persisters.Access.AccessPersister(); }, "Instantiation of the default constructor should not throw an exception"); return(obj); }
public void ConstructorWithMissingFile() { PFW.CSIST203.Project3.Persisters.Access.AccessPersister obj = null; var tmp = System.IO.Path.Combine(GetMethodSpecificWorkingDirectory(), System.Guid.NewGuid().ToString() + ".accdb"); AssertDelegateFailure(() => { obj = new Project3.Persisters.Access.AccessPersister(tmp); }, typeof(System.IO.FileNotFoundException), "An invalid file was supplied into the constructor and should have thrown a System.IO.FileNotFoundException"); Assert.IsNull(obj, "The variable should still be null because it could not be instantiated"); }
public void DefaultConstructor() { PFW.CSIST203.Project3.Persisters.Access.AccessPersister obj = null; AssertDelegateSuccess(() => { obj = new Project3.Persisters.Access.AccessPersister(); }, "Instantiation using the empty constructor should not throw an exception"); Assert.IsTrue(string.IsNullOrWhiteSpace(obj.accessFile), "The access file variable should not be set when the parameterless constructor is used"); Assert.IsTrue(obj.noDatabase, "The boolean value indicating no backing database is available should return true"); }
/// <summary> /// Refactored method for creating a persister that uses the sample access database embedded into the project /// </summary> /// <param name="workingDirectory">The method specific working directory</param> /// <returns>A persister instantiated using the sample access database</returns> protected PFW.CSIST203.Project3.Persisters.Access.AccessPersister CreatePersister(string workingDirectory) { PFW.CSIST203.Project3.Persisters.Access.AccessPersister obj = null; var tmpAccessDatabaseFile = System.IO.Path.Combine(workingDirectory, "sample-data.accdb"); CopyEmbeddedResourceBaseToDirectory("PFW.CSIST203.Project3.Tests.Resources.Data", workingDirectory); Assert.IsTrue(System.IO.File.Exists(tmpAccessDatabaseFile), "The sample data access database file was not found"); AssertDelegateSuccess(() => { obj = new Project3.Persisters.Access.AccessPersister(tmpAccessDatabaseFile); }, "Instantiation pointing to a file should not immediately throw an exception"); return(obj); }
public void ConstructorWithValidFile() { PFW.CSIST203.Project3.Persisters.Access.AccessPersister obj = null; var directory = GetMethodSpecificWorkingDirectory(); var tmpAccessDatabaseFile = System.IO.Path.Combine(directory, "sample-data.accdb"); CopyEmbeddedResourceBaseToDirectory("PFW.CSIST203.Project3.Tests.Resources.Data", directory); Assert.IsTrue(System.IO.File.Exists(tmpAccessDatabaseFile), "The sample data access database file was not found"); AssertDelegateSuccess(() => { obj = new Project3.Persisters.Access.AccessPersister(tmpAccessDatabaseFile); }, "Instantiation pointing to a file should not immediately throw an exception"); Assert.AreEqual(tmpAccessDatabaseFile, obj.accessFile, "The local variable should be set to the supplied file in the constructor"); Assert.IsFalse(obj.noDatabase, "A database file was supplied, so the boolean value should be set to false"); }