public void WhenReadFromStreamMethodIsCalledWithUnpositionedStreamTheReaderMustCallStreamSeekMethod() { var fakeFs = A.Fake <IFileSystem>(); var fakeMsf = A.Fake <IMemoryStreamFactory>(); var fakeStream = A.Fake <System.IO.MemoryStream>(); A.CallTo(() => fakeStream.CanRead).Returns(true); A.CallTo(() => fakeStream.Length).Returns(1); A.CallTo(() => fakeStream.Position).Returns(1); A.CallTo(() => fakeStream.Seek(0, System.IO.SeekOrigin.Begin)).Returns(0); var readerclass = new XmlSchemaReader(fakeFs, fakeMsf); try { readerclass.ReadFromStream(fakeStream); } #pragma warning disable CC0004 // Catch block cannot be empty catch (Exception) { // do nothing } #pragma warning restore CC0004 // Catch block cannot be empty A.CallTo(() => fakeStream.Seek(0, System.IO.SeekOrigin.Begin)).MustHaveHappened(); }
public void WhenReadFromStreamMethodIsCalledWithNonReadableStreamTheReaderMustThrowArgumentException() { var fakeFs = A.Fake <IFileSystem>(); var fakeMsf = A.Fake <IMemoryStreamFactory>(); var fakeStream = A.Fake <System.IO.MemoryStream>(); A.CallTo(() => fakeStream.CanRead).Returns(false); var readerclass = new XmlSchemaReader(fakeFs, fakeMsf); readerclass.ReadFromStream(fakeStream); Assert.Fail("Should not reach this point."); }