public void ResetStreamPosition_ResetsModuleStreamSourcePosition() { // Arrange const int dummyInitialPosition = 1; Mock <Stream> mockStream = _mockRepository.Create <Stream>(); mockStream.Setup(s => s.Position).Returns(dummyInitialPosition); // Constructor saves initial position mockStream.Setup(s => s.CanSeek).Returns(true); var testSubject = new InvocationRequest(ModuleSourceType.Stream, moduleStreamSource: mockStream.Object); // Act testSubject.ResetStreamPosition(); // Assert _mockRepository.VerifyAll(); mockStream.VerifySet(s => s.Position = dummyInitialPosition); }
public void ResetStreamPosition_ThrowsInvalidOperationExceptionIfModuleStreamSourceIsUnseekable() { // Arrange Mock <Stream> mockStream = _mockRepository.Create <Stream>(); mockStream.Setup(s => s.CanSeek).Returns(false); var testSubject = new InvocationRequest(ModuleSourceType.Stream, moduleStreamSource: mockStream.Object); // Act and assert InvalidOperationException result = Assert.Throws <InvalidOperationException>(() => testSubject.ResetStreamPosition()); _mockRepository.VerifyAll(); Assert.Equal(Strings.InvalidOperationException_InvocationRequest_StreamIsUnseekable, result.Message); }
public void ResetStreamPosition_ThrowsInvalidOperationExceptionIfModuleStreamSourceIsNull() { // Arrange var testSubject = new InvocationRequest(ModuleSourceType.String, "dummyModuleSource"); // Act and assert InvalidOperationException result = Assert.Throws <InvalidOperationException>(() => testSubject.ResetStreamPosition()); Assert.Equal(Strings.InvalidOperationException_InvocationRequest_StreamIsNull, result.Message); }