public void CheckStreamAtInitialPosition_ReturnsFalseIfModuleStreamSourceIsNotAtInitialPosition() { // Arrange Mock <Stream> mockStream = _mockRepository.Create <Stream>(); mockStream.SetupSequence(s => s.Position). Returns(1). Returns(2); // Return different values when caching initial position and when comparing mockStream.Setup(s => s.CanSeek).Returns(true); var testSubject = new InvocationRequest(ModuleSourceType.Stream, moduleStreamSource: mockStream.Object); // Act bool result = testSubject.CheckStreamAtInitialPosition(); // Assert _mockRepository.VerifyAll(); Assert.False(result); }
public void CheckStreamAtInitialPosition_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.CheckStreamAtInitialPosition()); _mockRepository.VerifyAll(); Assert.Equal(Strings.InvalidOperationException_InvocationRequest_StreamIsUnseekable, result.Message); }
public void CheckStreamAtInitialPosition_ThrowsInvalidOperationExceptionIfModuleStreamSourceIsNull() { // Arrange var testSubject = new InvocationRequest(ModuleSourceType.String, "dummyModuleSource"); // Act and assert InvalidOperationException result = Assert.Throws <InvalidOperationException>(() => testSubject.CheckStreamAtInitialPosition()); Assert.Equal(Strings.InvalidOperationException_InvocationRequest_StreamIsNull, result.Message); }