示例#1
0
        public void ExecuteWritesViewToStream()
        {
            // Given
            var view = A.Fake<IView>();
            A.CallTo(() => view.Execute()).Invokes(x => view.Writer.Write("Test"));
            var result = new ViewResult(view, "location");
            var stream = new MemoryStream();

            // When
            result.Execute(stream);

            // Then
            stream.Position = 0;
            using (var reader = new StreamReader(stream)) {
                reader.ReadToEnd().ShouldEqual("Test");
            }
        }
示例#2
0
        public void ExecuteWritesViewToStream()
        {
            // arrange
            var view = A.Fake <IView>();

            A.CallTo(() => view.Execute()).Invokes(x => view.Writer.Write("Test"));
            var result = new ViewResult(view, "location");
            var stream = new MemoryStream();

            // act
            result.Execute(stream);

            // assert
            stream.Position = 0;
            using (var reader = new StreamReader(stream)) {
                reader.ReadToEnd().ShouldEqual("Test");
            }
        }