Permalink
Browse files

DAL - basic skeleton, add test parsing results

  • Loading branch information...
srmrco committed Mar 22, 2015
1 parent 139bdd8 commit c8db80e4aa13c46aec715b7601b82fbee3580359

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,12 @@
using QuoteService.Models;
namespace QuoteService.Interfaces
{
public interface IQueryBuilder
{
City City { get; set; }
Currency Currency { get; set; }
string Build();
}
}
@@ -0,0 +1,9 @@
namespace QuoteService.Interfaces
{
public interface IQuoteDataProvider
{
IQueryBuilder QueryBuilder { get; set; }
string GetQuoteDocumentText();
}
}
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using QuoteService.Models;
namespace QuoteService.Interfaces
{
public interface IQuoteService
{
IQuoteDataProvider DataProvider { get; }
IEnumerable<ExchangeData> GetExchangeRates();
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuoteService.Models
{
public enum City
{
Moscow = 1,
StPete = 2
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuoteService.Models
{
public enum Currency
{
EURRUB = 2,
USDRUB = 3
}
}
@@ -0,0 +1,23 @@
using System;
namespace QuoteService.Models
{
public class ExchangeData
{
public string Name { get; set; }
public decimal? BuyRate { get; set; }
public decimal? SellRate { get; set; }
public string Commission { get; set; }
public decimal? AvailableAmount { get; set; }
public string Comments { get; set; }
public DateTime DateCreated { get; set; }
public decimal? Distance { get; set; }
}
}
@@ -13,7 +13,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile32</TargetFrameworkProfile>
<TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -37,12 +37,16 @@
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<TargetPlatform Include="WindowsPhoneApp, Version=8.1" />
<TargetPlatform Include="Windows, Version=8.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Interfaces\IQueryBuilder.cs" />
<Compile Include="Interfaces\IQuoteDataProvider.cs" />
<Compile Include="Interfaces\IQuoteService.cs" />
<Compile Include="Models\City.cs" />
<Compile Include="Models\Currency.cs" />
<Compile Include="Models\ExchangeData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\Rbc\QueryBuilder.cs" />
<Compile Include="Services\Rbc\QuoteDataProvider.cs" />
<Compile Include="Services\Rbc\QuoteService.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -0,0 +1,18 @@
using System;
using QuoteService.Interfaces;
using QuoteService.Models;
namespace QuoteService.Services.Rbc
{
public class QueryBuilder : IQueryBuilder
{
public City City { get; set; }
public Currency Currency { get; set; }
public string Build()
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,25 @@
using System;
using QuoteService.Interfaces;
namespace QuoteService.Services.Rbc
{
public class QuoteDataProvider : IQuoteDataProvider
{
public IQueryBuilder QueryBuilder { get; set; }
public QuoteDataProvider()
{
QueryBuilder = new QueryBuilder();
}
public QuoteDataProvider(IQueryBuilder queryBuilder)
{
QueryBuilder = queryBuilder;
}
public string GetQuoteDocumentText()
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using QuoteService.Interfaces;
using QuoteService.Models;
namespace QuoteService.Services.Rbc
{
public class QuoteService : IQuoteService
{
public IQuoteDataProvider DataProvider { get; private set; }
public QuoteService()
{
DataProvider = new QuoteDataProvider();
}
public QuoteService(IQuoteDataProvider provider)
{
DataProvider = provider;
}
public IEnumerable<ExchangeData> GetExchangeRates()
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,34 @@
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuoteService.Models;
using QuoteService.Services.Rbc;
using Tests.Unit.Utils;
using QS = QuoteService.Services.Rbc.QuoteService;
namespace Tests.Unit
{
[TestClass]
public class RbcQuoteServiceTest
{
[TestMethod]
public void TestResultsParsed()
{
var queryBuilder = new QueryBuilder { City = City.StPete, Currency = Currency.USDRUB };
var quoteProvider = new MockQuoteDataProvider { QueryBuilder = queryBuilder };
var service = new QS(quoteProvider);
var result = service.GetExchangeRates();
var exchangeDatas = result as ExchangeData[] ?? result.ToArray();
Assert.IsTrue(exchangeDatas.Any());
foreach (var item in exchangeDatas)
{
Assert.IsNotNull(item.Name);
Assert.IsTrue(item.BuyRate.HasValue || item.SellRate.HasValue);
Assert.IsFalse(item.DateCreated == DateTime.MinValue);
}
}
}
}
@@ -50,8 +50,15 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RbcQuoteServiceTest.cs" />
<Compile Include="Utils\MockQuoteDataProvider.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Services\QuoteService\QuoteService.csproj">
<Project>{10FDA89D-C911-458C-8E3B-B6ACEC9701C5}</Project>
<Name>QuoteService</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,15 @@
using System;
using QuoteService.Interfaces;
namespace Tests.Unit.Utils
{
public class MockQuoteDataProvider : IQuoteDataProvider
{
public IQueryBuilder QueryBuilder { get; set; }
public string GetQuoteDocumentText()
{
throw new NotImplementedException();
}
}
}

0 comments on commit c8db80e

Please sign in to comment.