/// <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"); }