Skip to content

Commit 28107bb

Browse files
committed
Merge pull request #50 from msallin/Issue-23
Issue 23
2 parents 825170b + 96915ca commit 28107bb

35 files changed

+670
-27
lines changed

Lib/Moq.dll

649 KB
Binary file not shown.

SQLite.CodeFirst.Console/FootballDbContext.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
2929

3030
private static void ConfigureTeamEntity(DbModelBuilder modelBuilder)
3131
{
32-
modelBuilder.Entity<Team>();
33-
34-
modelBuilder.Entity<Team>()
32+
modelBuilder.Entity<Team>().ToTable("Base.MyTable")
3533
.HasRequired(t => t.Coach)
3634
.WithMany()
3735
.WillCascadeOnDelete(false);

SQLite.CodeFirst.Console/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Runtime.InteropServices;
33

44
[assembly: AssemblyTitle("SQLite.CodeFirst")]
5-
[assembly: AssemblyDescription("A console application which demonstrates how to use QLite.CodeFirst.")]
5+
[assembly: AssemblyDescription("A console application which demonstrates how to use SQLite.CodeFirst.")]
66
[assembly: AssemblyProduct("SQLite.CodeFirst")]
77
[assembly: AssemblyCopyright("Copyright © Marc Sallin")]
88

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("SQLite.CodeFirst.Test")]
5+
[assembly: AssemblyDescription("Contains the Unit Tests for the SQLite.CodeFirst Library.")]
6+
[assembly: AssemblyProduct("SQLite.CodeFirst")]
7+
[assembly: AssemblyCopyright("Copyright © Marc Sallin")]
8+
9+
// Setting ComVisible to false makes the types in this assembly not visible
10+
// to COM components. If you need to access a type in this assembly from
11+
// COM, set the ComVisible attribute to true on that type.
12+
[assembly: ComVisible(false)]
13+
14+
[assembly: AssemblyVersion("1.0.0.0")]
15+
[assembly: AssemblyFileVersion("1.0.0.0")]
16+
[assembly: AssemblyInformationalVersion("1.0.0.0")]
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{E542F38D-852E-489D-81C2-BF333503E10F}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>SQLite.CodeFirst.Test</RootNamespace>
10+
<AssemblyName>SQLite.CodeFirst.Test</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
39+
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
40+
<Private>True</Private>
41+
</Reference>
42+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
43+
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
44+
<Private>True</Private>
45+
</Reference>
46+
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
47+
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
48+
<Private>True</Private>
49+
<SpecificVersion>False</SpecificVersion>
50+
<HintPath>..\Lib\Moq.dll</HintPath>
51+
</Reference>
52+
<Reference Include="System" />
53+
<Reference Include="System.ComponentModel.DataAnnotations" />
54+
</ItemGroup>
55+
<Choose>
56+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
57+
<ItemGroup>
58+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
59+
</ItemGroup>
60+
</When>
61+
<Otherwise>
62+
<ItemGroup>
63+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
64+
<Private>False</Private>
65+
</Reference>
66+
</ItemGroup>
67+
</Otherwise>
68+
</Choose>
69+
<ItemGroup>
70+
<Compile Include="Properties\AssemblyInfo.cs" />
71+
<Compile Include="Statement\ColumnConstraint\MaxLengthConstraint.cs" />
72+
<Compile Include="Statement\ColumnConstraint\ColumnConstraintCollectionTest.cs" />
73+
<Compile Include="Statement\ColumnConstraint\NotNullConstraintTest.cs" />
74+
<Compile Include="Statement\ColumnStatementCollectionTest.cs" />
75+
<Compile Include="Statement\PrimaryKeyStatementTest.cs" />
76+
<Compile Include="Statement\CreateDatabaseStatementTest.cs" />
77+
<Compile Include="Statement\StatementTestBase.cs" />
78+
<Compile Include="Statement\ForeignKeyStatementTest.cs" />
79+
<Compile Include="Statement\CreateTableStatementTest.cs" />
80+
<Compile Include="Statement\CreateIndexStatementCollectionTest.cs" />
81+
<Compile Include="Statement\ColumnStatementTest.cs" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<Folder Include="Builder\" />
85+
<Folder Include="Convention\" />
86+
<Folder Include="Extensions\" />
87+
</ItemGroup>
88+
<ItemGroup>
89+
<ProjectReference Include="..\SQLite.CodeFirst\SQLite.CodeFirst.csproj">
90+
<Project>{50a32fe4-0e13-4213-a373-72523cdf34d9}</Project>
91+
<Name>SQLite.CodeFirst</Name>
92+
</ProjectReference>
93+
</ItemGroup>
94+
<ItemGroup>
95+
<None Include="packages.config" />
96+
</ItemGroup>
97+
<Choose>
98+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
99+
<ItemGroup>
100+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
101+
<Private>False</Private>
102+
</Reference>
103+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
104+
<Private>False</Private>
105+
</Reference>
106+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
107+
<Private>False</Private>
108+
</Reference>
109+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
110+
<Private>False</Private>
111+
</Reference>
112+
</ItemGroup>
113+
</When>
114+
</Choose>
115+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
116+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
117+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
118+
Other similar extension points exist, see Microsoft.Common.targets.
119+
<Target Name="BeforeBuild">
120+
</Target>
121+
<Target Name="AfterBuild">
122+
</Target>
123+
-->
124+
</Project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Moq;
3+
using SQLite.CodeFirst.Statement.ColumnConstraint;
4+
5+
namespace SQLite.CodeFirst.Test.Statement.ColumnConstraint
6+
{
7+
[TestClass]
8+
public class ColumnConstraintCollectionTest : StatementTestBase
9+
{
10+
[TestMethod]
11+
public void CreateStatementOneColumnConstraintTest()
12+
{
13+
var columnConstraintMock = new Mock<IColumnConstraint>();
14+
columnConstraintMock.Setup(c => c.CreateStatement()).Returns("dummy1");
15+
16+
var columnConstraintCollection = new ColumnConstraintCollection(new[]
17+
{
18+
columnConstraintMock.Object
19+
});
20+
string output = columnConstraintCollection.CreateStatement();
21+
Assert.AreEqual(output, "dummy1");
22+
}
23+
24+
[TestMethod]
25+
public void CreateStatementTwoColumnConstraintsTest()
26+
{
27+
var columnConstraintMock1 = new Mock<IColumnConstraint>();
28+
columnConstraintMock1.Setup(c => c.CreateStatement()).Returns("dummy1");
29+
30+
var columnConstraintMock2 = new Mock<IColumnConstraint>();
31+
columnConstraintMock2.Setup(c => c.CreateStatement()).Returns("dummy2");
32+
33+
var columnConstraintCollection = new ColumnConstraintCollection(new[]
34+
{
35+
columnConstraintMock1.Object,
36+
columnConstraintMock2.Object
37+
});
38+
string output = columnConstraintCollection.CreateStatement();
39+
Assert.AreEqual(output, "dummy1 dummy2");
40+
}
41+
}
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SQLite.CodeFirst.Statement.ColumnConstraint;
4+
5+
namespace SQLite.CodeFirst.Test.Statement.ColumnConstraint
6+
{
7+
[TestClass]
8+
public class MaxLengthConstraintTest : StatementTestBase
9+
{
10+
[TestMethod]
11+
public void CreateStatementTest()
12+
{
13+
var maxLengthConstraint = new MaxLengthConstraint(12);
14+
string output = maxLengthConstraint.CreateStatement();
15+
Assert.AreEqual(output, "(12)");
16+
}
17+
18+
[TestMethod]
19+
[ExpectedException(typeof(InvalidOperationException))]
20+
public void CreateStatementInvalidParameterTest()
21+
{
22+
var maxLengthConstraint = new MaxLengthConstraint();
23+
maxLengthConstraint.CreateStatement();
24+
}
25+
}
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using SQLite.CodeFirst.Statement.ColumnConstraint;
3+
4+
namespace SQLite.CodeFirst.Test.Statement.ColumnConstraint
5+
{
6+
[TestClass]
7+
public class NotNullConstraintTest : StatementTestBase
8+
{
9+
[TestMethod]
10+
public void CreateStatementTest()
11+
{
12+
var notNullConstraint = new NotNullConstraint();
13+
string output = notNullConstraint.CreateStatement();
14+
Assert.AreEqual(output, "NOT NULL");
15+
}
16+
}
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using SQLite.CodeFirst.Statement;
3+
4+
namespace SQLite.CodeFirst.Test.Statement
5+
{
6+
[TestClass]
7+
public class ColumnStatementCollectionTest : StatementTestBase
8+
{
9+
[TestMethod]
10+
public void CreateStatementOneEntryTest()
11+
{
12+
var columnStatementCollection = new ColumnStatementCollection(new[] { CreateStatementMock("dummy1").Object });
13+
14+
string output = columnStatementCollection.CreateStatement();
15+
Assert.AreEqual(columnStatementCollection.Count, 1);
16+
Assert.AreEqual(output, "dummy1");
17+
}
18+
19+
[TestMethod]
20+
public void CreateStatementTwoEntryTest()
21+
{
22+
var createIndexStatementCollection = new ColumnStatementCollection(new[]
23+
{
24+
CreateStatementMock("dummy1").Object,
25+
CreateStatementMock("dummy2").Object
26+
});
27+
28+
string output = createIndexStatementCollection.CreateStatement();
29+
Assert.AreEqual(createIndexStatementCollection.Count, 2);
30+
Assert.AreEqual(output, "dummy1, dummy2");
31+
}
32+
}
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Moq;
3+
using SQLite.CodeFirst.Statement;
4+
using SQLite.CodeFirst.Statement.ColumnConstraint;
5+
6+
namespace SQLite.CodeFirst.Test.Statement
7+
{
8+
[TestClass]
9+
public class ColumnStatementTest : StatementTestBase
10+
{
11+
[TestMethod]
12+
public void CreateStatement()
13+
{
14+
var columnConstraintsMock = new Mock<IColumnConstraintCollection>();
15+
columnConstraintsMock.Setup(c => c.CreateStatement()).Returns("dummyColumnConstraint");
16+
17+
var columnStatement = new ColumnStatement
18+
{
19+
ColumnConstraints = columnConstraintsMock.Object,
20+
ColumnName = "dummyColumnName",
21+
TypeName = "dummyType"
22+
};
23+
string output = columnStatement.CreateStatement();
24+
Assert.AreEqual(output, "[dummyColumnName] dummyType dummyColumnConstraint");
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)