private IRecordedOutput getOutputWithEtag(string etag)
        {
            var output = new RecordedOutput(null);

            output.AppendHeader(HttpResponseHeaders.ETag, etag);

            return(output);
        }
Example #2
0
        protected override void beforeEach()
        {
            theContent     = "some content";
            theContentType = "text/xml";

            theRecordedOutput = ClassUnderTest.Record(() =>
            {
                ClassUnderTest.Write(theContentType, theContent);
            }).As <RecordedOutput>();
        }
Example #3
0
 public bool Equals(RecordedOutput other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Content, Content) && Equals(other.RecordedContentType, RecordedContentType));
 }
 public AppFlowGameEngine(
     ILogger <GameEngine> logger,
     IOptions <AllOptions> options,
     IEnumerable <State> states,
     ISpinConfiguration spinConfiguration,
     Wallet wallet,
     RecordedOutput output)
     : base(logger, options, states, spinConfiguration, wallet)
 {
     _wallet = wallet;
     _output = output;
     _steps  = new List <AppFlowStep>();
 }
Example #5
0
        public void should_not_generate_data_on_cache_hit()
        {
            var theValue = new RecordedOutput("test/html", "View:Brandon");

            MockFor <ICacheProvider>().Stub(cp => cp.Get(theKey)).Return(theValue);

            execute();

            MockFor <ICacheProvider>().AssertWasNotCalled(cp => cp.Insert(theKey, theValue, cacheOptions.Dependency, cacheOptions.AbsoluteExpiration, cacheOptions.SlidingExpiration));

            generatorWasCalled.ShouldBeFalse();
            wasCalled.ShouldBeTrue();
        }
        public void recorded_output()
        {
            Action action            = () => { };
            var    theRecordedOutput = new RecordedOutput("content type", "the output");

            MockFor <IOutputWriter>().Stub(x => x.Record(action)).Return(theRecordedOutput);

            ClassUnderTest.Record(action);

            MockFor <IDebugReport>().AssertWasCalled(x => x.AddDetails(new OutputReport()
            {
                Contents    = theRecordedOutput.Content,
                ContentType = theRecordedOutput.RecordedContentType
            }));
        }
Example #7
0
        public virtual IRecordedOutput Record(Action action)
        {
            var output = new RecordedOutput(_fileSystem);
            _state = output;

            try
            {
                action();
            }
            finally
            {
                revertToNormalWriting();
            }

            return output;
        }
Example #8
0
        public virtual IRecordedOutput Record(Action action)
        {
            var output = new RecordedOutput(_fileSystem);
            _outputStates.Push(output);

            try
            {
                action();
            }
            finally
            {
                _outputStates.Pop();
            }

            return output;
        }
Example #9
0
        protected override void beforeEach()
        {
            theContent       = "some content";
            theNestedContent = "nested content";
            theContentType   = "text/xml";

            theRecordedOutput = ClassUnderTest.Record(() =>
            {
                ClassUnderTest.Write(theContentType, theContent);
                theNestedOutput = ClassUnderTest.Record(() =>
                {
                    ClassUnderTest.Write(theContentType, theNestedContent);
                    return(Task.CompletedTask);
                }).GetAwaiter().GetResult().As <RecordedOutput>();

                return(Task.CompletedTask);
            }).GetAwaiter().GetResult().As <RecordedOutput>();
        }
Example #10
0
        public virtual async Task<IRecordedOutput> Record(Func<Task> inner)
        {
            _logger.DebugMessage(() => new StartedRecordingOutput());

            var output = new RecordedOutput(_fileSystem);
            _outputStates.Push(output);

            try
            {
                await inner().ConfigureAwait(false);
            }
            finally
            {
                _outputStates.Pop();
            
                _logger.DebugMessage(() => new FinishedRecordingOutput(output));
            }

            return output;
        }
Example #11
0
        public virtual IRecordedOutput Record(Action action)
        {
            _logger.DebugMessage(() => new StartedRecordingOutput());

            var output = new RecordedOutput(_fileSystem);
            _outputStates.Push(output);

            try
            {
                action();
            }
            finally
            {
                _outputStates.Pop();

                _logger.DebugMessage(() => new FinishedRecordingOutput());
            }

            return output;
        }
Example #12
0
        public void Eject_clears()
        {
            Func <IRecordedOutput> shouldNotBeCalled = () =>
            {
                Assert.Fail("Do not call me");
                return(null);
            };

            var output1 = getOutputWithEtag("12345");

            theOutputCache.Retrieve("12345", () => output1).ShouldBeTheSameAs(output1);
            theOutputCache.Eject("12345");

            var output2 = new RecordedOutput(null);

            theOutputCache.Retrieve("12345", () => output2).ShouldBeTheSameAs(output2);
            theOutputCache.Retrieve("12345", shouldNotBeCalled).ShouldBeTheSameAs(output2);
            theOutputCache.Retrieve("12345", shouldNotBeCalled).ShouldBeTheSameAs(output2);
            theOutputCache.Retrieve("12345", shouldNotBeCalled).ShouldBeTheSameAs(output2);
            theOutputCache.Retrieve("12345", shouldNotBeCalled).ShouldBeTheSameAs(output2);
            theOutputCache.Retrieve("12345", shouldNotBeCalled).ShouldBeTheSameAs(output2);
        }
Example #13
0
 public StubOutputWriter() : base(new NulloHttpWriter(), null, new RecordingLogger())
 {
     Output = new RecordedOutput(null);
 }
Example #14
0
 public void SetUp()
 {
     theHttpResponse   = MockRepository.GenerateMock <IHttpResponse>();
     theRecordedOutput = new RecordedOutput(new FileSystem());
 }
Example #15
0
 public FinishedRecordingOutput(RecordedOutput output)
 {
     _output = output;
 }
Example #16
0
 public bool Equals(RecordedOutput other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Content, Content) && Equals(other.RecordedContentType, RecordedContentType);
 }
Example #17
0
 public StubOutputWriter() : base(new OwinHttpResponse(), null, new RecordingLogger())
 {
     Output = new RecordedOutput(null);
 }