using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Rhino.Mocks;
|
|
using Sevomin.Models.Helpers;
|
|
using Sevomin.WebFrontend.Controllers;
|
|
using System.Security.Principal;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace Sevomin.Tests.Controllers.Job
|
|
{
|
|
[TestClass]
|
|
public class NewJob
|
|
{
|
|
HttpContextBase fakeContext = MockRepository.GenerateStub<HttpContextBase>();
|
|
|
|
public JobController GetCUT()
|
|
{
|
|
FakeJobRepository.Init();
|
|
fakeContext = MockRepository.GenerateStub<HttpContextBase>();
|
|
fakeContext.User = MockRepository.GenerateStub<IPrincipal>();
|
|
fakeContext.User.Stub(x => x.Identity).Return(new FakeIdentity());
|
|
|
|
JobController cut = new JobController(FakeJobRepository.Instance(),
|
|
MockRepository.GenerateMock<SevominUserManager>(FakeDbContext.Instance()), fakeContext);
|
|
return cut;
|
|
}
|
|
|
|
[TestMethod]
|
|
public void MyTestMethod()
|
|
{
|
|
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task Returns_View_NewJob_JobController()
|
|
{
|
|
// Arrange
|
|
JobController cut = GetCUT();
|
|
// Act
|
|
var result = (await cut.NewJob()) as ViewResult;
|
|
// Assert
|
|
Assert.IsNotNull(result);
|
|
Assert.AreEqual(string.Empty, result.ViewName);
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task Returns_EmptyJobModel_NewJob_JobController()
|
|
{
|
|
// Arrange
|
|
JobController cut = GetCUT();
|
|
// Act
|
|
var result = (await cut.NewJob()) as ViewResult;
|
|
// Assert
|
|
Assert.IsNotNull(result);
|
|
Assert.IsNotNull(result.Model);
|
|
Assert.IsInstanceOfType(result.Model, typeof(Models.Job));
|
|
Assert.AreNotEqual((result.Model as Models.Job).JobParameters.Count, 0);
|
|
}
|
|
}
|
|
}
|