Browse Source

JobRepository

confirmation-email
J 11 years ago
parent
commit
442f542b70
6 changed files with 42 additions and 5 deletions
  1. +2
    -2
      Sevomin.Models/Parameter.cs
  2. +3
    -0
      Sevomin.Models/ParameterValue.cs
  3. +10
    -0
      Sevomin.Models/Sevomin.Models.csproj
  4. +21
    -2
      Sevomin.Tests/Controllers/Job/NewJob.cs
  5. +1
    -0
      Sevomin.Tests/Sevomin.Tests.csproj
  6. +5
    -1
      Sevomin.WebFrontend.Controllers/JobController.cs

+ 2
- 2
Sevomin.Models/Parameter.cs View File

@ -37,11 +37,11 @@ namespace Sevomin.Models
public string ParameterValueId { get; set; }
[NotMapped]
public ICollection<ParameterValue> ParameterValues
public IQueryable<ParameterValue> ParameterValues
{
get
{
return SevominDbContext.Current.ParameterValues.Where(x => x.GroupKey == ParameterValueId).ToList();
return SevominDbContext.Current.ParameterValues.Where(x => x.GroupKey == ParameterValueId);
}
}


+ 3
- 0
Sevomin.Models/ParameterValue.cs View File

@ -22,5 +22,8 @@ namespace Sevomin.Models
[Column(Order = 2)]
[StringLength(50)]
public string Value { get; set; }
[Required]
public decimal NumbericValue { get; set; }
}
}

+ 10
- 0
Sevomin.Models/Sevomin.Models.csproj View File

@ -67,6 +67,7 @@
<Compile Include="Helpers\SevominUserValidator.cs" />
<Compile Include="Job.cs" />
<Compile Include="JobParameter.cs" />
<Compile Include="JobParameterViewModel.cs" />
<Compile Include="LoginViewModel.cs" />
<Compile Include="Migrations\201403261205298_InitialCreate.cs" />
<Compile Include="Migrations\201403261205298_InitialCreate.Designer.cs">
@ -96,11 +97,17 @@
<Compile Include="Migrations\201403281016428_JobParameter.Designer.cs">
<DependentUpon>201403281016428_JobParameter.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201403290719225_ParameterValue Change.cs" />
<Compile Include="Migrations\201403290719225_ParameterValue Change.Designer.cs">
<DependentUpon>201403290719225_ParameterValue Change.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Parameter.cs" />
<Compile Include="ParameterValue.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\IRepository.cs" />
<Compile Include="Repositories\JobRepository.cs" />
<Compile Include="Repositories\ParameterRepository.cs" />
<Compile Include="SignupViewModel.cs" />
<Compile Include="User.cs" />
<Compile Include="UsersDbContext.cs" />
@ -131,6 +138,9 @@
<EmbeddedResource Include="Migrations\201403281016428_JobParameter.resx">
<DependentUpon>201403281016428_JobParameter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201403290719225_ParameterValue Change.resx">
<DependentUpon>201403290719225_ParameterValue Change.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.


+ 21
- 2
Sevomin.Tests/Controllers/Job/NewJob.cs View File

@ -12,17 +12,36 @@ namespace Sevomin.Tests.Controllers.Job
[TestClass]
public class NewJob
{
public JobController GetCUT()
{
JobController cut = new JobController();
return cut;
}
[TestMethod]
public void Returns_View_NewJob_JobController()
{
// Arrange
JobController cut = new JobController();
JobController cut = GetCUT();
// Act
var result = cut.NewJob() as ViewResult;
// Assert
Assert.IsNotNull(result);
Assert.AreEqual(string.Empty, result.ViewName);
}
[TestMethod]
public void Returns_EmptyJobModel_NewJob_JobController()
{
// Arrange
JobController cut = GetCUT();
// Act
var result = 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);
}
}
}

+ 1
- 0
Sevomin.Tests/Sevomin.Tests.csproj View File

@ -75,6 +75,7 @@
</Choose>
<ItemGroup>
<Compile Include="Controllers\Job\NewJob.cs" />
<Compile Include="FakeJobRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>


+ 5
- 1
Sevomin.WebFrontend.Controllers/JobController.cs View File

@ -4,14 +4,18 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Sevomin.Models;
using Sevomin.Models.Repositories;
namespace Sevomin.WebFrontend.Controllers
{
public class JobController : AuthorizedController
{
public ActionResult NewJob()
{
return View();
Avalin avalin = null;
return View(JobRepository.Current.GetEmptyJobFor(avalin));
}
}


Loading…
Cancel
Save