public void TestDirty() { Document dm = new Document(); Assert.IsFalse(dm.Dirty); dm.Text = "abc"; Assert.IsTrue(dm.Dirty); dm.FileName = @"c:\abc.wordo"; DynamicMock fs = new DynamicMock(typeof (IFileSystem)); dm.Save((IFileSystem)fs.MockInstance); Assert.IsFalse(dm.Dirty); dm.Text = "abc2"; Assert.IsTrue(dm.Dirty); dm.Save((IFileSystem)fs.MockInstance); Assert.IsFalse(dm.Dirty); fs.ExpectAndReturn("ReadAllText", "abc3", @"c:\abc.wordo"); dm.Load((IFileSystem)fs.MockInstance); Assert.AreEqual("abc3", dm.Text); Assert.IsFalse(dm.Dirty); }
public void TestSave() { Document dm = new Document(); dm.Text = "abc"; dm.FileName = @"c:\abc.wordo"; DynamicMock fs = new DynamicMock(typeof (IFileSystem)); fs.Expect("WriteAllText", @"c:\abc.wordo", "abc"); dm.Save((IFileSystem)fs.MockInstance); fs.Verify(); }