public void ShouldBeAbleToAssertSpecificActionForASetup() { IFileReader fileReader = Mock.Create <IFileReader>(); fileReader.Arrange(x => x.Delete()).OccursOnce(); fileReader.Delete(); fileReader.Assert(x => x.Delete()); }
public void ShouldBeAbleToAssertSpecificFuntionForASetup() { IFileReader fileReader = Mock.Create <IFileReader>(); const string expected = @"c:\JustMock"; fileReader.Arrange(x => x.Path).Returns(expected).OccursOnce(); Assert.Equal(expected, fileReader.Path); fileReader.Assert(x => x.Path); }
public void ShouldArrangeAssertMockUsingFluentInterface() { //Arrange const string baseDir = @"C:\Foo\Sub1\Sub2\Sub3\Sub4"; IFileReader fileReader = Mock.Create <IFileReader>(); fileReader.Arrange(x => x.GetDirectoryParent(baseDir, 4)).Returns(@"C:\Foo\").Occurs(1); //Act var handler = new DataFileHandler(fileReader); var parent = handler.GetDirectoryParent(baseDir, 4); //Assert Assert.Equal(@"C:\Foo\", parent); fileReader.Assert(); }