Skip to content

Instantly share code, notes, and snippets.

@jmkelly
Created August 23, 2011 03:58
Show Gist options
  • Save jmkelly/1164314 to your computer and use it in GitHub Desktop.
Save jmkelly/1164314 to your computer and use it in GitHub Desktop.
TinyWeb Handler Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Midway.Mobile.Web.Handlers;
using NSubstitute;
using Midway.Infrastructure.Logging;
using Midway.Infrastructure.Mappings;
using Midway.Infrastructure.Services;
using tinyweb.framework;
using tinyweb.viewengine.spark;
using Should;
namespace Midway.Mobile.Web.Tests.Handler
{
[TestFixture]
class StakeholderHandlerTest
{
[SetUp]
public void init()
{
Automappings.Initialise();
}
[Test]
public void StakeholderSearchGetHandlerTester()
{
var logger = Substitute.For<ILogger>();
IConnectionString conn = new TestConnectionString();
StakeholderSearchHandler handler = new StakeholderSearchHandler(logger, conn);
var result = handler.Get("james") as SparkResult;
result.ViewPath.ShouldEqual("Views/Stakeholders/Index.spark");
}
[Test]
public void StakeholderGetHandlerTester()
{
var logger = Substitute.For<ILogger>();
IConnectionString conn = new TestConnectionString();
StakeholdersHandler handler = new StakeholdersHandler(logger, conn);
var result = handler.Get() as SparkResult;
result.ViewPath.ShouldEqual("Views/Stakeholders/Index.spark");
}
[Test]
public void LoginFailedTest()
{
var logger = Substitute.For<ILogger>();
var auth = Substitute.For<IAuthenticationService>();
auth.IsValidLogin("username", "incorrect_password").Returns(false);
LoginHandler handler = new LoginHandler(logger, auth);
var result = handler.Post("username", "incorrect_password") as SparkResult;
result.ViewPath.ShouldEqual("Views/Login/Login.spark");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment