Skip to content

Commit

Permalink
Initial tests port to MVC6
Browse files Browse the repository at this point in the history
- Added initial lookup tests port to MVC6.
  • Loading branch information
Muchiachio committed Dec 5, 2015
1 parent fab3e35 commit 7ef0611
Show file tree
Hide file tree
Showing 30 changed files with 2,761 additions and 6 deletions.
11 changes: 10 additions & 1 deletion Mvc.Lookup.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F7BEFA84-7DFD-4529-BBD6-AF8C7539834B}"
EndProject
Expand All @@ -15,6 +15,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mvc.Lookup", "src\Mvc.Looku
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mvc.Lookup.Core", "src\Mvc.Lookup.Core\Mvc.Lookup.Core.xproj", "{A4F395F4-96C6-4BFD-BE93-DFDA64979EA2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{2502DA8F-A481-4EF7-84CC-9F7A3CEDB09E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mvc.Lookup.Tests", "test\Mvc.Lookup.Tests\Mvc.Lookup.Tests.xproj", "{3E245F3E-D204-43FB-9FD9-DD501EA8054D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,12 +33,17 @@ Global
{A4F395F4-96C6-4BFD-BE93-DFDA64979EA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4F395F4-96C6-4BFD-BE93-DFDA64979EA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4F395F4-96C6-4BFD-BE93-DFDA64979EA2}.Release|Any CPU.Build.0 = Release|Any CPU
{3E245F3E-D204-43FB-9FD9-DD501EA8054D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E245F3E-D204-43FB-9FD9-DD501EA8054D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E245F3E-D204-43FB-9FD9-DD501EA8054D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E245F3E-D204-43FB-9FD9-DD501EA8054D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6B0FE95A-672E-453D-9F1C-A77EA7CFB48E} = {F7BEFA84-7DFD-4529-BBD6-AF8C7539834B}
{A4F395F4-96C6-4BFD-BE93-DFDA64979EA2} = {F7BEFA84-7DFD-4529-BBD6-AF8C7539834B}
{3E245F3E-D204-43FB-9FD9-DD501EA8054D} = {2502DA8F-A481-4EF7-84CC-9F7A3CEDB09E}
EndGlobalSection
EndGlobal
8 changes: 5 additions & 3 deletions src/Mvc.Lookup.Core/GenericLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ protected virtual LookupData FormLookupData(IQueryable<T> models)
data.FilteredRecords = models.Count();
data.Columns = Columns;

IQueryable<T> pagedModels = models
.Skip(CurrentFilter.Page * CurrentFilter.RecordsPerPage)
.Take(CurrentFilter.RecordsPerPage);
IQueryable<T> pagedModels = CurrentFilter.Page != 0 && CurrentFilter.RecordsPerPage != 0
? models
.Skip(CurrentFilter.Page * CurrentFilter.RecordsPerPage)
.Take(CurrentFilter.RecordsPerPage)
: new T[0].AsQueryable();

foreach (T model in pagedModels)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc.Lookup.Core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"System.Linq.Dynamic": "1.0.4",
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final"
},

"compilationOptions": {
"warningsAsErrors": true
},
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc.Lookup/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"authors": [ "NonFactors" ],
"tags": [ "mvc lookup" ],
"version": "0.9.1",

"compilationOptions": {
"warningsAsErrors": true
},
Expand Down
21 changes: 21 additions & 0 deletions test/Mvc.Lookup.Tests/Mvc.Lookup.Tests.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>3e245f3e-d204-43fb-9fd9-dd501ea8054d</ProjectGuid>
<RootNamespace>Mvc.Lookup.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
15 changes: 15 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Data/Context.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Data.Entity;

namespace NonFactors.Mvc.Lookup.Tests.Objects.Data
{
public class Context : DbContext
{
public DbSet<TestModel> TestModels { get; set; }
public DbSet<TestRelationModel> TestRelationModels { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Mvc6LookupTest;Trusted_Connection=True;MultipleActiveResultSets=True");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.Data.Entity.Migrations;
using System;

namespace Mvc.Lookup.Tests.Objects.Data.Migrations
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TestRelationModel",
columns: table => new
{
Id = table.Column<string>(nullable: false),
NoValue = table.Column<string>(nullable: true),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TestRelationModel", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TestModel",
columns: table => new
{
Id = table.Column<string>(nullable: false),
CreationDate = table.Column<DateTime>(nullable: false),
FirstRelationModelId = table.Column<string>(nullable: true),
NullableString = table.Column<string>(nullable: true),
Number = table.Column<int>(nullable: false),
ParentId = table.Column<string>(nullable: true),
SecondRelationModelId = table.Column<string>(nullable: true),
Sum = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TestModel", x => x.Id);
table.ForeignKey(
name: "FK_TestModel_TestRelationModel_FirstRelationModelId",
column: x => x.FirstRelationModelId,
principalTable: "TestRelationModel",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_TestModel_TestRelationModel_SecondRelationModelId",
column: x => x.SecondRelationModelId,
principalTable: "TestRelationModel",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("TestModel");
migrationBuilder.DropTable("TestRelationModel");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using NonFactors.Mvc.Lookup.Tests.Objects.Data;

namespace Mvc.Lookup.Tests.Objects.Data.Migrations
{
[DbContext(typeof(Context))]
partial class ContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "7.0.0-rc1-16348");

modelBuilder.Entity("NonFactors.Mvc.Lookup.Tests.Objects.TestModel", b =>
{
b.Property<string>("Id");

b.Property<DateTime>("CreationDate");

b.Property<string>("FirstRelationModelId");

b.Property<string>("NullableString");

b.Property<int>("Number");

b.Property<string>("ParentId");

b.Property<string>("SecondRelationModelId");

b.Property<decimal>("Sum");

b.HasKey("Id");
});

modelBuilder.Entity("NonFactors.Mvc.Lookup.Tests.Objects.TestRelationModel", b =>
{
b.Property<string>("Id");

b.Property<string>("NoValue");

b.Property<string>("Value");

b.HasKey("Id");
});

modelBuilder.Entity("NonFactors.Mvc.Lookup.Tests.Objects.TestModel", b =>
{
b.HasOne("NonFactors.Mvc.Lookup.Tests.Objects.TestRelationModel")
.WithMany()
.HasForeignKey("FirstRelationModelId");

b.HasOne("NonFactors.Mvc.Lookup.Tests.Objects.TestRelationModel")
.WithMany()
.HasForeignKey("SecondRelationModelId");
});
}
}
}
8 changes: 8 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/EnumModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public class EnumModel
{
[LookupColumn]
public IdEnum Id { get; set; }
}
}
8 changes: 8 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/IdEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public enum IdEnum
{
Id,
Null
}
}
10 changes: 10 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/NoIdModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public class NoIdModel
{
[LookupColumn]
public String Title { get; set; }
}
}
10 changes: 10 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/NoRelationModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public class NoRelationModel
{
[LookupColumn(Relation = "None")]
public String NoRelation { get; set; }
}
}
10 changes: 10 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/NonNumericIdModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public class NonNumericIdModel
{
[LookupColumn]
public Guid Id { get; set; }
}
}
10 changes: 10 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/NumericIdModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public class NumericIdModel
{
[LookupColumn]
public Decimal Id { get; set; }
}
}
33 changes: 33 additions & 0 deletions test/Mvc.Lookup.Tests/Objects/Models/TestModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.ComponentModel.DataAnnotations;

namespace NonFactors.Mvc.Lookup.Tests.Objects
{
public class TestModel
{
[LookupColumn(0)]
public String Id { get; set; }

[LookupColumn]
[Display(Name = "TestDisplay")]
public Int32 Number { get; set; }

[Lookup(typeof(TestLookupProxy))]
public String ParentId { get; set; }

[LookupColumn(-5, Format = "{0:d}")]
public DateTime CreationDate { get; set; }

public Decimal Sum { get; set; }
public String NullableString { get; set; }

public String FirstRelationModelId { get; set; }
public String SecondRelationModelId { get; set; }

[LookupColumn(1, Relation = "Value")]
public virtual TestRelationModel FirstRelationModel { get; set; }

[LookupColumn(1, Relation = "NoValue")]
public virtual TestRelationModel SecondRelationModel { get; set; }
}
}
Loading

0 comments on commit 7ef0611

Please sign in to comment.