Skip to content

Commit

Permalink
Merge pull request #4 from cheesemacfly/netstandard
Browse files Browse the repository at this point in the history
Netstandard
  • Loading branch information
cheesemacfly authored Dec 21, 2017
2 parents 488c805 + 6ccb535 commit 38a0ade
Show file tree
Hide file tree
Showing 25 changed files with 171 additions and 405 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
nuget.exe

# User-specific files
.vs/
*.suo
*.user
*.userosscache
Expand Down
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: csharp
solution: MTAServiceStatus.sln
before_install:
- sudo apt-get install nunit-console
before_script:
- nuget restore MTAServiceStatus.sln
after_script:
- nunit-console Tests/bin/Release/Tests.dll
mono: none
dotnet: 2.0.0

install:
- dotnet restore

script:
- dotnet build
- dotnet test MTAServiceStatus.Tests/MTAServiceStatus.Tests.csproj
63 changes: 63 additions & 0 deletions MTAServiceStatus.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System.Threading.Tasks;
using Xunit;

namespace MTAServiceStatus.Tests
{
public class IntegrationTests
{

[Fact(DisplayName = "Get Lines")]
public async Task GetLinesAsyncTests()
{
var status = new MTASubwayStatus();

var lines = await status.GetLinesAsync();

Assert.NotNull(lines);

Assert.NotEmpty(lines);
}

[Fact(DisplayName = "Get Raw Service")]
public async Task GetRawServiceAsyncTests()
{
var repo = new MTARepository();

var result = await repo.GetRawServiceAsync();

Assert.NotNull(result);

Assert.NotEmpty(result.BT);

Assert.NotEmpty(result.Bus);

Assert.NotEmpty(result.LIRR);

Assert.NotEmpty(result.MetroNorth);

Assert.NotEmpty(result.Subway);

Assert.Equal(0, result.ResponseCode);
}

[Fact(DisplayName = "Get Service")]
public async Task GetServiceAsyncTests()
{
var repo = new MTARepository();

var result = await repo.GetServiceAsync();

Assert.NotNull(result);

Assert.NotEmpty(result.BT);

Assert.NotEmpty(result.Bus);

Assert.NotEmpty(result.LIRR);

Assert.NotEmpty(result.MetroNorth);

Assert.NotEmpty(result.Subway);
}
}
}
20 changes: 20 additions & 0 deletions MTAServiceStatus.Tests/MTAServiceStatus.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MTAServiceStatus\MTAServiceStatus.csproj" />
</ItemGroup>

</Project>
32 changes: 20 additions & 12 deletions MTAServiceStatus.sln
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTAServiceStatus", "MTAServiceStatus\MTAServiceStatus.csproj", "{8CF4C896-D955-4D6E-A796-BCE9E54BE849}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTAServiceStatus", "MTAServiceStatus\MTAServiceStatus.csproj", "{197A8518-9891-409A-BD2B-A73D9B5923B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{698E932F-9B11-4DD1-A9CA-85A9E63204FF}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{37A27582-D7B8-4EFB-9210-CA712A45D975}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTAServiceStatus.Tests", "MTAServiceStatus.Tests\MTAServiceStatus.Tests.csproj", "{5535941F-CD40-4926-B565-309810862D76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8CF4C896-D955-4D6E-A796-BCE9E54BE849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CF4C896-D955-4D6E-A796-BCE9E54BE849}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CF4C896-D955-4D6E-A796-BCE9E54BE849}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CF4C896-D955-4D6E-A796-BCE9E54BE849}.Release|Any CPU.Build.0 = Release|Any CPU
{698E932F-9B11-4DD1-A9CA-85A9E63204FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{698E932F-9B11-4DD1-A9CA-85A9E63204FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{698E932F-9B11-4DD1-A9CA-85A9E63204FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{698E932F-9B11-4DD1-A9CA-85A9E63204FF}.Release|Any CPU.Build.0 = Release|Any CPU
{197A8518-9891-409A-BD2B-A73D9B5923B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{197A8518-9891-409A-BD2B-A73D9B5923B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{197A8518-9891-409A-BD2B-A73D9B5923B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{197A8518-9891-409A-BD2B-A73D9B5923B6}.Release|Any CPU.Build.0 = Release|Any CPU
{5535941F-CD40-4926-B565-309810862D76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5535941F-CD40-4926-B565-309810862D76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5535941F-CD40-4926-B565-309810862D76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5535941F-CD40-4926-B565-309810862D76}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5535941F-CD40-4926-B565-309810862D76} = {37A27582-D7B8-4EFB-9210-CA712A45D975}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {91353209-D81B-4346-AE8E-C510F9029C7A}
EndGlobalSection
EndGlobal
19 changes: 0 additions & 19 deletions MTAServiceStatus/Configs/AutoMapperConfig.cs

This file was deleted.

6 changes: 3 additions & 3 deletions MTAServiceStatus/Extensions/XmlSerializerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Xml;
using System.Xml.Serialization;

namespace MTAServiceStatus.Extensions
namespace MTAServiceStatus
{
public static class XmlSerializerExtensions
internal static class XmlSerializerExtensions
{
/// <summary>
/// Deserializes the XML document contained by the specified System.xml.XmlReader.
Expand All @@ -13,7 +13,7 @@ public static class XmlSerializerExtensions
/// <param name="xmlReader">The System.xml.XmlReader that contains the XML document to deserialize.</param>
/// <returns>The T object being deserialized or null if the wrong type is requested.</returns>
/// <exception cref="System.InvalidOperationException"/>
public static T Deserialize<T>(this XmlSerializer input, XmlReader xmlReader) where T : class
internal static T Deserialize<T>(this XmlSerializer input, XmlReader xmlReader) where T : class
{
return input.Deserialize(xmlReader) as T;
}
Expand Down
87 changes: 14 additions & 73 deletions MTAServiceStatus/MTAServiceStatus.csproj
Original file line number Diff line number Diff line change
@@ -1,77 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8CF4C896-D955-4D6E-A796-BCE9E54BE849}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MTAServiceStatus</RootNamespace>
<AssemblyName>MTAServiceStatus</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>netstandard2.0</TargetFramework>
<Authors>Cheesemacfly</Authors>
<Product>MTAServiceStatus</Product>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
<Description>Get the latest New York City MTA service status</Description>
<PackageLicenseUrl>https://github.com/cheesemacfly/MTAServiceStatus/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/cheesemacfly/MTAServiceStatus</PackageProjectUrl>
<Version>0.0.0.0</Version>
</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="AutoMapper">
<HintPath>..\packages\AutoMapper.3.3.0\lib\net40\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="AutoMapper.Net4">
<HintPath>..\packages\AutoMapper.3.3.0\lib\net40\AutoMapper.Net4.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configs\AutoMapperConfig.cs" />
<Compile Include="Extensions\XmlSerializerExtensions.cs" />
<Compile Include="Models\Api\Line.cs" />
<Compile Include="Models\Api\RawLine.cs" />
<Compile Include="Models\Api\RawService.cs" />
<Compile Include="Models\Api\Service.cs" />
<Compile Include="Models\ServiceStatus.cs" />
<Compile Include="Models\SubwayLine.cs" />
<Compile Include="MTASubwayStatus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\MTARepository.cs" />
<Compile Include="Resolvers\LineDateTimeResolver.cs" />
<Compile Include="Resolvers\ServiceStatusResolver.cs" />
</ItemGroup>

<ItemGroup>
<None Include="MTAServiceStatus.nuspec" />
<None Include="packages.config" />
<PackageReference Include="AutoMapper" Version="6.2.2" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\AutoMapper.3.3.0\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.0\tools\AutoMapper.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>
15 changes: 0 additions & 15 deletions MTAServiceStatus/MTAServiceStatus.nuspec

This file was deleted.

15 changes: 7 additions & 8 deletions MTAServiceStatus/MTASubwayStatus.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using MTAServiceStatus.Models;
using MTAServiceStatus.Repositories;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MTAServiceStatus
{
public class MTASubwayStatus
public sealed class MTASubwayStatus
{
private readonly string[] SubwayNames = new[] { "1", "2", "3", "4", "5", "6", "A", "C", "E", "B", "D", "F", "M", "G", "J", "Z", "L", "N", "Q", "R", "S", "SIR" };
private readonly MTARepository _repo;
Expand Down Expand Up @@ -41,14 +40,14 @@ public async Task<List<SubwayLine>> GetLinesAsync()
{
var line = service.Subway.OrderBy(s => s.Name).FirstOrDefault(s => s.Name.Contains(name));

var subwayLine = new SubwayLine
{
Name = name,
Status = null == line ?
ServiceStatus.UNKNOWN : line.Text.Contains(string.Format("[{0}]", name)) ?
var subwayLine = new SubwayLine
{
Name = name,
Status = null == line ?
ServiceStatus.NONE : line.Text.Contains(string.Format("[{0}]", name)) ?
line.Status : ServiceStatus.GOOD_SERVICE
};

result.Add(subwayLine);
}

Expand Down
2 changes: 1 addition & 1 deletion MTAServiceStatus/Models/Api/Line.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace MTAServiceStatus.Models.Api
namespace MTAServiceStatus.Models
{
public class Line
{
Expand Down
2 changes: 1 addition & 1 deletion MTAServiceStatus/Models/Api/RawLine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Xml.Serialization;

namespace MTAServiceStatus.Models.Api
namespace MTAServiceStatus.Models
{
public class RawLine
{
Expand Down
4 changes: 2 additions & 2 deletions MTAServiceStatus/Models/Api/RawService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace MTAServiceStatus.Models.Api
namespace MTAServiceStatus.Models
{
[XmlRoot("service")]
public class RawService
Expand All @@ -28,5 +28,5 @@ public class RawService
[XmlArray("subway")]
[XmlArrayItem("line")]
public List<RawLine> Subway { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion MTAServiceStatus/Models/Api/Service.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;

namespace MTAServiceStatus.Models.Api
namespace MTAServiceStatus.Models
{
public class Service
{
Expand Down
2 changes: 1 addition & 1 deletion MTAServiceStatus/Models/ServiceStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public enum ServiceStatus
{
UNKNOWN,
NONE,
GOOD_SERVICE,
PLANNED_WORK,
SERVICE_CHANGE,
Expand Down
Loading

0 comments on commit 38a0ade

Please sign in to comment.