Skip to content

Commit 91e3fe4

Browse files
committed
Merge branch 'feature/SQL-unit-tests' into develop
Established initial unit tests for stored procedures and functions in the `dbo` schema. Stored procedures: - `CreateTopic` (e77013b) - `DeleteTopic` (b136726) - `GetTopics` (ac0d9b9) - `GetTopicVersion` (d625089, 3b44745) - `MoveTopic` (63069ba, 1fb3016) - `UpdateAttributes` (d697fb0) - `UpdateExtendedAttributes` (69c0500) - `UpdateReferences` (8214f92) - `UpdateRelationships` (04eb1bc) - `UpdateTopic` (f184d19) Functions: - `GetAttributes` (156e734) - `FindTopicIDs` (6d69fa6) - `GetChildTopicIDs` (4c80bb0) - `GetExtendedAttribute` (dd5e015) - `GetParentID` (b08055e) - `GetTopicID` (d6991e7) - `GetUniqueKey` (40b50fa) As part of this, I also uncovered and fixed a couple of bugs: - `GetChildTopicIDs` was still operating off of `Attributes` not `Topics` (eb03f08) - `Load(Topic, DateTime)` was causing a compile-time error due to a last-minute parameter refactoring (732b1e0)
2 parents 0e808ea + dd5e015 commit 91e3fe4

File tree

13 files changed

+3989
-5
lines changed

13 files changed

+3989
-5
lines changed

OnTopic.Data.Sql.Database.Tests/Functions.cs

Lines changed: 495 additions & 0 deletions
Large diffs are not rendered by default.

OnTopic.Data.Sql.Database.Tests/Functions.resx

Lines changed: 696 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Incompatible with generated code", Scope = "namespaceanddescendants", Target = "~N:OnTopic.Data.Sql.Database.Tests")]
9+
[assembly: SuppressMessage("Style", "IDE0003:Remove qualification", Justification = "Incompatible with generated code", Scope = "namespaceanddescendants", Target = "~N:OnTopic.Data.Sql.Database.Tests")]
10+
[assembly: SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Incompatible with generated code", Scope = "namespaceanddescendants", Target = "~N:OnTopic.Data.Sql.Database.Tests")]
11+
[assembly: SuppressMessage("Style", "IDE0007:Use implicit type", Justification = "Incompatible with generated code", Scope = "namespaceanddescendants", Target = "~N:OnTopic.Data.Sql.Database.Tests")]
12+
[assembly: SuppressMessage("Style", "IDE0022:Use expression body for methods", Justification = "Incompatible with generated code", Scope = "namespaceanddescendants", Target = "~N:OnTopic.Data.Sql.Database.Tests")]
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SSDTUnitTestPath Condition="'$(SSDTUnitTestPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB</SSDTUnitTestPath>
5+
</PropertyGroup>
6+
<PropertyGroup>
7+
<SSDTPath Condition="'$(SSDTPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130</SSDTPath>
8+
</PropertyGroup>
9+
<PropertyGroup>
10+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
11+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
12+
<ProjectGuid>{D7FE876D-A75F-4493-8283-B316271FD5AE}</ProjectGuid>
13+
<OutputType>Library</OutputType>
14+
<AppDesignerFolder>Properties</AppDesignerFolder>
15+
<RootNamespace>OnTopic.Data.Sql.Database.Tests</RootNamespace>
16+
<AssemblyName>OnTopic.Data.Sql.Database.Tests</AssemblyName>
17+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
18+
<FileAlignment>512</FileAlignment>
19+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
20+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
21+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
22+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
23+
<IsCodedUITest>False</IsCodedUITest>
24+
<TestProjectType>UnitTest</TestProjectType>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
27+
<DebugSymbols>true</DebugSymbols>
28+
<DebugType>full</DebugType>
29+
<Optimize>false</Optimize>
30+
<OutputPath>bin\Debug\</OutputPath>
31+
<DefineConstants>DEBUG;TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
36+
<DebugType>pdbonly</DebugType>
37+
<Optimize>true</Optimize>
38+
<OutputPath>bin\Release\</OutputPath>
39+
<DefineConstants>TRACE</DefineConstants>
40+
<ErrorReport>prompt</ErrorReport>
41+
<WarningLevel>4</WarningLevel>
42+
</PropertyGroup>
43+
<ItemGroup>
44+
<Reference Include="System" />
45+
<Reference Include="System.Data" />
46+
</ItemGroup>
47+
<Choose>
48+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
49+
<ItemGroup>
50+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
51+
</ItemGroup>
52+
</When>
53+
<Otherwise>
54+
<ItemGroup>
55+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
56+
</ItemGroup>
57+
</Otherwise>
58+
</Choose>
59+
<ItemGroup>
60+
<Compile Include="Functions.cs">
61+
<SubType>Designer</SubType>
62+
</Compile>
63+
<Compile Include="GlobalSuppressions.cs" />
64+
<Compile Include="SqlDatabaseSetup.cs" />
65+
<Compile Include="StoredProcedures.cs">
66+
<SubType>Designer</SubType>
67+
</Compile>
68+
<Compile Include="Properties\AssemblyInfo.cs" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<None Include="app.config" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<EmbeddedResource Include="Functions.resx">
75+
<DependentUpon>Functions.cs</DependentUpon>
76+
</EmbeddedResource>
77+
<EmbeddedResource Include="StoredProcedures.resx">
78+
<DependentUpon>StoredProcedures.cs</DependentUpon>
79+
</EmbeddedResource>
80+
</ItemGroup>
81+
<ItemGroup />
82+
<ItemGroup Condition="$(VisualStudioVersion) == '16.0'">
83+
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
84+
<HintPath>$(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
85+
<Private>True</Private>
86+
</Reference>
87+
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
88+
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll</HintPath>
89+
<Private>True</Private>
90+
</Reference>
91+
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
92+
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll</HintPath>
93+
<Private>True</Private>
94+
</Reference>
95+
</ItemGroup>
96+
<Choose>
97+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
98+
<ItemGroup>
99+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
100+
<Private>False</Private>
101+
</Reference>
102+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
103+
<Private>False</Private>
104+
</Reference>
105+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
106+
<Private>False</Private>
107+
</Reference>
108+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
109+
<Private>False</Private>
110+
</Reference>
111+
</ItemGroup>
112+
</When>
113+
</Choose>
114+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
115+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
116+
<PropertyGroup>
117+
<SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
118+
</PropertyGroup>
119+
<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" />
120+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" />
121+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
122+
Other similar extension points exist, see Microsoft.Common.targets.
123+
<Target Name="BeforeBuild">
124+
</Target>
125+
<Target Name="AfterBuild">
126+
</Target>
127+
-->
128+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("OnTopic.Data.Sql.Database.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("OnTopic.Data.Sql.Database.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("d7fe876d-a75f-4493-8283-b316271fd5ae")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Data.Common;
6+
using Microsoft.Data.Tools.Schema.Sql.UnitTesting;
7+
using Microsoft.VisualStudio.TestTools.UnitTesting;
8+
9+
namespace OnTopic.Data.Sql.Database.Tests {
10+
[TestClass()]
11+
public class SqlDatabaseSetup {
12+
13+
[AssemblyInitialize()]
14+
public static void InitializeAssembly(TestContext ctx) {
15+
// Setup the test database based on setting in the
16+
// configuration file
17+
SqlDatabaseTestClass.TestService.DeployDatabaseProject();
18+
SqlDatabaseTestClass.TestService.GenerateData();
19+
}
20+
21+
}
22+
}

0 commit comments

Comments
 (0)