public void CreateFileTest_ParamFailureFilename() { // arrange DashboardFileFactory target = new DashboardFileFactory(); string temp = null; // act try { DashboardFile file = target.CreateFile(this.contents, temp); Assert.Fail("exception not thrown"); } catch (ArgumentNullException) { } catch { Assert.Fail("Invalid exception"); } }
public void CreateFileTest_Success() { // arrange DashboardFileFactory target = new DashboardFileFactory(); // act DashboardFile file = target.CreateFile(this.contents, this.filename); // assert Assert.IsNotNull(file); Assert.AreSame(this.contents, file.FileContents); Assert.AreSame(this.filename, file.FileName); }
public void SaveTest_Success() { // arrange DashboardFileFactory target = new DashboardFileFactory(); DashboardFile file = target.CreateFile(this.contents, this.filename); // act target.Save(file); // assert Assert.IsTrue(File.Exists(file.FileName)); // cleanup File.Delete(file.FileName); }
public void SaveTest_ParamFailure() { // arrange DashboardFileFactory target = new DashboardFileFactory(); // act try { target.Save(null); Assert.Fail("exception not thrown"); } catch (ArgumentNullException) { } catch { Assert.Fail("Invalid exception"); } }
public void ReadTest_Success() { // arrange DashboardFileFactory target = new DashboardFileFactory(); DashboardFile file = target.CreateFile(this.contents, this.filename); target.Save(file); // act string actual = target.Read(file); // assert Assert.AreEqual(this.contents, actual); // cleanup File.Delete(file.FileName); }
public void ReadTest_FailureFileNotFound() { // arrange DashboardFileFactory target = new DashboardFileFactory(); DashboardFile file = target.CreateFile(this.contents, "bogusname.txt"); // act try { target.Read(file); Assert.Fail("exception not thrown"); } catch (FileNotFoundException) { } catch { Assert.Fail("Invalid exception"); } }
public void ExistsTest_SuccessFalse() { // arrange DashboardFileFactory target = new DashboardFileFactory(); DashboardFile file = target.CreateFile(this.contents, this.filename); // act bool actual = target.Exists(file); // assert Assert.IsFalse(actual); }