public void Invoke_ShouldHandleAndReturn200() { //Arrange var context = _fixture.Create <IOwinContext>(); _handlerPool.Add(new ThermometerHandler(new ThermometerQuestion("/abc", "def"), req => new { result = "ghi" })); context.Stub(x => x.Request).Return(_fixture.Create <IOwinRequest>()); context.Request.Stub(x => x.Path).Return(new PathString("/abc")); //context.Request.Stub(x => x.ToThermometerQuestion()).Return(new ThermometerQuestion("/abc", "/abc")); IOwinResponse response = MockRepository.GenerateStub <IOwinResponse>(); context.Stub(x => x.Response).Return(response); context.Response.Stub(x => x.WriteAsJson(Arg <object> .Is.Anything)); response.StatusCode = 200; _nextMiddleware.Stub(x => x.Invoke(context)).Return(Task.FromResult("success")); //Act _sut.Invoke(context); //Assert context.Response.AssertWasCalled(x => x.WriteAsJson(Arg <object> .Is.Anything)); Assert.AreEqual(200, response.StatusCode); _nextMiddleware.AssertWasCalled(x => x.Invoke(context)); }
public void Init() { _fixture = new Fixture().Customize(new AutoRhinoMockCustomization()); _nextMiddleware = MockRepository.GenerateMock <OwinMiddleware>(new FakeRootMiddelware()); _handlerPool = new ThermometerRouteHandlerPool(); _handlerPool.Add(new ThermometerHandler(new ThermometerQuestion("/abc", "def"), req => new { result = "ghi" })); _sut = new ListAllQuestionMiddleware(_nextMiddleware, _handlerPool); }
public void Init() { _fixture = new Fixture().Customize(new AutoRhinoMockCustomization()); _nextMiddleware = MockRepository.GenerateMock<OwinMiddleware>(new FakeRootMiddelware()); _handlerPool = new ThermometerRouteHandlerPool(); _handlerPool.Add(new ThermometerHandler(new ThermometerQuestion("/abc", "def"), req => new {result = "ghi"})); _sut = new ListAllQuestionMiddleware(_nextMiddleware, _handlerPool); }
public void FindOrDefault_ShouldFind() { //Arrange ThermometerHandler th = new ThermometerHandler(new ThermometerQuestion("/abc"), question => "def?"); ThermometerRouteHandlerPool tp = new ThermometerRouteHandlerPool(); tp.Add(th); //Act //Assert Assert.AreEqual(th, tp.FindOrDefault("/abc")); Assert.IsNull(tp.FindOrDefault("/def")); }
public void Add_ShouldAddOneElement() { //Arrange ThermometerHandler th = new ThermometerHandler(new ThermometerQuestion("/abc"), question => "def?"); ThermometerRouteHandlerPool tp = new ThermometerRouteHandlerPool(); //Act tp.Add(th); //Assert Assert.AreEqual(1, tp.Count()); Assert.AreEqual(th, tp.First()); }
public void FindOrDefault_ShouldFind() { //Arrange ThermometerHandler th = new ThermometerHandler(new ThermometerQuestion("/abc"), question => "def?"); ThermometerRouteHandlerPool tp = new ThermometerRouteHandlerPool(); tp.Add(th); //Act //Assert Assert.AreEqual(th,tp.FindOrDefault("/abc")); Assert.IsNull(tp.FindOrDefault("/def")); }
public void Contains_ShouldReturnByRoute() { //Arrange ThermometerHandler th = new ThermometerHandler(new ThermometerQuestion("/abc"), question => "def?"); ThermometerRouteHandlerPool tp = new ThermometerRouteHandlerPool(); tp.Add(th); //Act //Assert Assert.IsTrue(tp.Contains("/abc")); Assert.IsFalse(tp.Contains("/def")); }
public void Add_ShouldAddOneElement() { //Arrange ThermometerHandler th = new ThermometerHandler(new ThermometerQuestion("/abc"), question => "def?" ); ThermometerRouteHandlerPool tp = new ThermometerRouteHandlerPool(); //Act tp.Add(th); //Assert Assert.AreEqual(1, tp.Count()); Assert.AreEqual(th, tp.First()); }
public void Contains_ShouldReturnByRoute() { //Arrange ThermometerHandler th = new ThermometerHandler(new ThermometerQuestion("/abc"), question => "def?"); ThermometerRouteHandlerPool tp = new ThermometerRouteHandlerPool(); tp.Add(th); //Act //Assert Assert.IsTrue(tp.Contains("/abc")); Assert.IsFalse(tp.Contains("/def")); }