Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thanks for opportunity. was fun #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{06DF4A00-EA47-467D-860E-DD0F949ABDC3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AnyCompany.IntegrationTests</RootNamespace>
<AssemblyName>AnyCompany.IntegrationTests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomerServiceIntegrationTests.cs" />
<Compile Include="OrderServiceIntegrationTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AnyCompany\AnyCompany.csproj">
<Project>{c7e15594-7d8f-4c18-9dd7-14f3fbb1572d}</Project>
<Name>AnyCompany</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="CreateSeededDb.Sql" />
<Content Include="Readme.txt" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" />
</Project>
47 changes: 47 additions & 0 deletions TechTest/AnyCompany.IntegrationTests/CreateSeededDb.Sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
CREATE DATABASE [Customers]
GO

CREATE TABLE [Customers].[dbo].[Customer](
[CustomerId] [int] NOT NULL,
[Country] [nvarchar](3) NOT NULL,
[DateOfBirth] [date] NOT NULL,
[Name] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED
(
[CustomerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT INTO [Customers].[dbo].[Customer]
([CustomerId],[Country],[DateOfBirth],[Name])
VALUES
(1, 'ZA', '1980-04-16', 'bob'),
(2, 'ZA', '1991-09-23', 'jill'),
(3, 'UK', '1985-03-01', 'sarah');


CREATE DATABASE [Orders]
GO

CREATE TABLE [Orders].[dbo].[Orders](
[OrderId] [int] NOT NULL,
[CustomerId] [int] NOT NULL,
[Amount] [float] NOT NULL,
[VAT] [float] NOT NULL,
CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED
(
[OrderId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT INTO [Orders].[dbo].[Orders]
([OrderId] ,[CustomerId] ,[Amount] ,[VAT])
VALUES
(1, 1, 50, 0),
(2, 1, 60, 0),
(3, 2, 70, 0),
(4, 2, 80, 0),
(5, 3, 90, 0.2),
(6, 4, 100, 0.2);
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AnyCompany.IntegrationTests
{
[TestClass]
public class CustomerServiceIntegrationTests
{
private ICustomerService _customerService;

public CustomerServiceIntegrationTests()
{
Config config = new Config();

var customerRepository = new CustomerRepositoryProxy(config.CustomerDbConnectionString);

var orderRepository = new OrderRepository(config.OrdersDbConnectionString);

_customerService = new CustomerService(orderRepository, customerRepository);
}

[TestMethod]
public void GetAllCustomersWithOrders_Successfully()
{
// Arrange

// Act
var customers = _customerService.GetAllCustomersWithOrders();

// Assert
Assert.IsTrue(customers.Count() > 0);
foreach (var customer in customers)
{
Assert.IsTrue(customer.Orders.Count() > 0);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AnyCompany.IntegrationTests
{
[TestClass]
public class OrderServiceIntegrationTests
{
private IOrderService _orderService;

public OrderServiceIntegrationTests()
{
Config config = new Config();

var customerRepository = new CustomerRepositoryProxy(config.CustomerDbConnectionString);

var orderRepository = new OrderRepository(config.OrdersDbConnectionString);

_orderService = new OrderService(orderRepository, customerRepository);
}

[TestMethod]
public void PlaceOrder_Successfully()
{
// Arrange
Order newOrder = new Order()
{
CustomerId = 1,
OrderId = 100,
Amount = 100,
VAT = 100
};

// Act
var isOrderPlaced = _orderService.PlaceOrder(newOrder, 1);

// Assert
Assert.AreEqual(true, isOrderPlaced);
}
}
}
20 changes: 20 additions & 0 deletions TechTest/AnyCompany.IntegrationTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("AnyCompany.IntegrationTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AnyCompany.IntegrationTests")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("06df4a00-ea47-467d-860e-dd0f949abdc3")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
13 changes: 13 additions & 0 deletions TechTest/AnyCompany.IntegrationTests/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


====== Sql Container ======
docker run -e ACCEPT_EULA=Y -e SA_PASSWORD=zaq1ZAQ! -p 1434:1433 -d --name sqlserver --network testnet --net-alias ss mcr.microsoft.com/mssql/server:2017-CU8-ubuntu

Connect to sql db and Run CreateSeededDb.Sql
server name: 127.0.0.1,1434
login: sa
password: zaq1ZAQ!

The above steps need to be scripted
Docker compose can start up db, migrations, SUT
So that everything is in correct state for integration tests
5 changes: 5 additions & 0 deletions TechTest/AnyCompany.IntegrationTests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.1.0" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.1.0" targetFramework="net472" />
</packages>
53 changes: 0 additions & 53 deletions TechTest/AnyCompany.Tests/AnyCompany.Tests.csproj

This file was deleted.

12 changes: 0 additions & 12 deletions TechTest/AnyCompany.Tests/Class1.cs

This file was deleted.

36 changes: 0 additions & 36 deletions TechTest/AnyCompany.Tests/Properties/AssemblyInfo.cs

This file was deleted.

Loading