public void StoreData_Database() { // Since this method hasn't been fully implemented, it will pass. HelloWorldAPI api = new HelloWorldAPI(); api.StoreData("More test data...", HelloWorldAPI.StorageType.Database); }
public void StoreData_Container_PathTooLong() { // Create an abnormally long path. string path = null; string longString = null; for (int i = 0; i < 1024; i++) { longString += "x"; } path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + longString; // Create a new API object. HelloWorldAPI api = new HelloWorldAPI(path); // Try storing our data. api.StoreData("Test data...", HelloWorldAPI.StorageType.Container); // Check our exceptions and assert. if (api.Errors.Count > 0) { Assert.IsInstanceOfType(api.Errors[0], typeof(PathTooLongException)); } else { throw new ApplicationException("No errors were found."); } }
public void StoreData_Container() { // Create a new API object. HelloWorldAPI api = new HelloWorldAPI(); // Store our data into a container. api.StoreData("More test data...", HelloWorldAPI.StorageType.Container); // Check if the file exists. Assert.IsTrue(File.Exists(api.ContainerPath)); }
public void StoreData_File() { // Create a new API object. HelloWorldAPI api = new HelloWorldAPI(); // Store our data into a file. api.StoreData("Some test data...", HelloWorldAPI.StorageType.File); // Check if the file exists. Assert.IsTrue(File.Exists(api.FilePath)); }
public void StoreData_Container_DirectoryNotFound() { // Create a new API object. HelloWorldAPI api = new HelloWorldAPI("This is not a real directory"); // Try storing our data into a non-existant file. api.StoreData("Invalid path data...", HelloWorldAPI.StorageType.Container); // Check our exceptions and assert. if (api.Errors.Count > 0) { Assert.IsInstanceOfType(api.Errors[0], typeof(DirectoryNotFoundException)); } else { throw new ApplicationException("No errors were found."); } }
public void StoreData_Container_UnauthorizedAccess() { /* Note - This unauthorized access test method will fail if run under * an adminstrator or higher elevated user. So, run it unprivileged. */ // Create a new API object. HelloWorldAPI api = new HelloWorldAPI(@"C:\Windows\System32"); // Try storing our data into a non-existant file. api.StoreData("Data being written...", HelloWorldAPI.StorageType.Container); // Check our exceptions and assert. if (api.Errors.Count > 0) { Assert.IsInstanceOfType(api.Errors[0], typeof(UnauthorizedAccessException)); } else { throw new ApplicationException("No errors were found."); } }