Skip to content

Commit

Permalink
Merge pull request #126 from keenlabs/jm_MergeDotNetSummer
Browse files Browse the repository at this point in the history
Merge dotnetsummer work. There are a few things to tidy up before cutting a new release an pushing the new .nupkg to NuGet, but we'll spin up another branch off master for those small items. Thanks!
  • Loading branch information
masojus authored Oct 11, 2017
2 parents 72457ff + 3063c4a commit b820c2e
Show file tree
Hide file tree
Showing 83 changed files with 9,085 additions and 142 deletions.
48 changes: 38 additions & 10 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ skip_tags: true
#---------------------------------#

image:
- Visual Studio 2015
- Visual Studio 2017

# scripts that are called at the very beginning, before repo cloning
Expand All @@ -38,7 +37,7 @@ init:
shallow_clone: true
clone_depth: 5

nuget:
nuget:
disable_publish_on_pr: true

environment:
Expand All @@ -48,7 +47,6 @@ environment:
# scripts that run after cloning repository
install:
# by default, all script lines are interpreted as batch
#- echo This is batch

matrix:
fast_finish: true
Expand All @@ -58,29 +56,59 @@ matrix:
# build configuration #
#---------------------------------#

configuration: Release
configuration:
# This config doesn't build the .NET Standard projects
- netfx

build:
parallel: true

# MSBuild verbosity level
verbosity: detailed
verbosity: normal

before_build:
- nuget restore
# Make sure we have the right tools version
- dotnet --version

# Restore non-netstandard projects one by one using nuget cli directly
- nuget restore .\Keen\Keen.csproj -PackagesDirectory .\packages\
- nuget restore .\Keen.Net\Keen.Net.csproj -PackagesDirectory .\packages\
- nuget restore .\Keen.NET.Test\Keen.NET.Test.csproj -PackagesDirectory .\packages\
- nuget restore .\Keen.NET_35\Keen.NET_35.csproj -PackagesDirectory .\packages\
- nuget restore .\Keen.NET_35.Test\Keen.NET_35.Test.csproj -PackagesDirectory .\packages\

# Restore netstandard projects one by one using dotnet cli
- dotnet restore .\Keen.NetStandard\Keen.NetStandard.csproj
- dotnet restore .\Keen.NetStandard.Test\Keen.NetStandard.Test.csproj

# scripts to run after build
after_build:


#---------------------------------#
# tests configuration #
#---------------------------------#

# Install tools needed for Code Coverage, run instrumented tests, and report coverage numbers
after_test:
test_script:
- nuget install OpenCover -Version 4.6.519 -OutputDirectory tools
- nuget install coveralls.net -Version 0.8.0-unstable0013 -PreRelease -OutputDirectory tools
- .\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:nunit3-console.exe -targetargs:"--noheader .\Keen.NET.Test\bin\Release\Keen.Net.Test.dll .\Keen.NET_35.Test\bin\Release\Keen.NET_35.Test.dll" -filter:"+[*]* -[*.Test]*" -register:user
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( .\tools\coveralls.net.0.8.0-unstable0013\tools\csmacnz.Coveralls.exe --opencover -i .\results.xml )

- .\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:nunit3-console.exe -targetargs:"--noheader .\Keen.NET.Test\bin\netfx\Keen.Net.Test.dll .\Keen.NET_35.Test\bin\netfx\Keen.NET_35.Test.dll --result=results.xml;format=AppVeyor" -output:coverage.xml -filter:"+[*]* -[*.Test]*" -returntargetcode -register:user

# Run the netstandard tests.
# Explicitly build with DebugType=Full specified. This means a non-portable, Windows-style PDB
# will be generated, which OpenCover currently requires. We can stop doing this once OpenCover supports the new
# portable PDB format.
#
# Also use -oldStyle flag which uses an alternate instrumentation hook that is available for .NET Core
# Some comments on this can be found here: https://github.com/OpenCover/opencover/issues/601
- .\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:dotnet.exe -targetargs:"test --logger \"trx;LogFileName=netstandard_test_results.xml\" .\Keen.NetStandard.Test\Keen.NetStandard.Test.csproj /property:DebugType=Full" -mergeoutput -output:coverage.xml -filter:"+[*]* -[*.Test]*" -oldStyle -returntargetcode -register:user

# Upload merged coverage results from both test runs
- .\tools\coveralls.net.0.8.0-unstable0013\tools\csmacnz.Coveralls.exe --opencover -i .\coverage.xml

# Upload netstandard test results to appveyor
- ps: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\Keen.NetStandard.Test\TestResults\netstandard_test_results.xml))

#---------------------------------#
# notifications #
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ build/
[Bb]in/
[Oo]bj/

# Visual Studio cache/options
.vs/

# NuGet Packages
*.nupkg
packages/
Expand Down Expand Up @@ -160,4 +163,10 @@ $RECYCLE.BIN/
.DS_Store

TestResult.xml
Keen.VisualState.xml
Keen.VisualState.xml

# Visual Studio Code
.vscode/

# Visual Studio for Mac
*.userprefs
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: csharp

# .NET Core version
dotnet: 2.0.0

# Don't bother with mono since we're doing a .NET Core-based build
mono: none

# OS matrix
os:
- linux
- osx

# Ubuntu version for the linux build
dist: trusty

# The image to use for the osx build
osx_image: xcode8.3

# Build and run the Keen.NetStandard project and run its tests
script: |
cd Keen.NetStandard.Test
dotnet test
8 changes: 2 additions & 6 deletions Keen.NET.Test/EventMock.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using Keen.Core.EventCache;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Keen.Core.EventCache;

namespace Keen.Core
{
Expand Down
9 changes: 9 additions & 0 deletions Keen.NET.Test/Keen.NET.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx|AnyCPU'">
<OutputPath>bin\netfx\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
Expand Down
84 changes: 43 additions & 41 deletions Keen.NET.Test/ProjectSettingsProviderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,59 @@ namespace Keen.Net.Test
public class ProjectSettingsProviderTest
{
[Test]
public void SettingsProviderEnv_VarsNotSet_Throws()
public void Settings_DefaultInputs_Success()
{
var ProjectId = Environment.GetEnvironmentVariable("KEEN_PROJECT_ID");
var MasterKey = Environment.GetEnvironmentVariable("KEEN_MASTER_KEY");
var WriteKey = Environment.GetEnvironmentVariable("KEEN_WRITE_KEY");
var ReadKey = Environment.GetEnvironmentVariable("KEEN_READ_KEY");
Assert.DoesNotThrow(() => new ProjectSettingsProvider("X", null));
}

try
{
Environment.SetEnvironmentVariable("KEEN_PROJECT_ID", null);
Environment.SetEnvironmentVariable("KEEN_MASTER_KEY", null);
Environment.SetEnvironmentVariable("KEEN_WRITE_KEY", null);
Environment.SetEnvironmentVariable("KEEN_READ_KEY", null);
[Test]
public void Settings_AllNull_Success()
{
Assert.DoesNotThrow(() => new ProjectSettingsProvider(null));
}

var settings = new ProjectSettingsProviderEnv();
Assert.Throws<KeenException>(() => new KeenClient(settings));
}
finally
{
Environment.SetEnvironmentVariable("KEEN_PROJECT_ID", ProjectId);
Environment.SetEnvironmentVariable("KEEN_MASTER_KEY", MasterKey);
Environment.SetEnvironmentVariable("KEEN_WRITE_KEY", WriteKey);
Environment.SetEnvironmentVariable("KEEN_READ_KEY", ReadKey);
}
[Test]
public void SettingsProviderEnv_VarsNotSet_Throws()
{
Environment.SetEnvironmentVariable(KeenConstants.KeenProjectId, null);
Environment.SetEnvironmentVariable(KeenConstants.KeenMasterKey, null);
Environment.SetEnvironmentVariable(KeenConstants.KeenWriteKey, null);
Environment.SetEnvironmentVariable(KeenConstants.KeenReadKey, null);

var settings = new ProjectSettingsProviderEnv();
Assert.Throws<KeenException>(() => new KeenClient(settings));
}

[Test]
public void SettingsProviderEnv_VarsSet_Success()
{
var ProjectId = Environment.GetEnvironmentVariable("KEEN_PROJECT_ID");
var MasterKey = Environment.GetEnvironmentVariable("KEEN_MASTER_KEY");
var WriteKey = Environment.GetEnvironmentVariable("KEEN_WRITE_KEY");
var ReadKey = Environment.GetEnvironmentVariable("KEEN_READ_KEY");
Environment.SetEnvironmentVariable(KeenConstants.KeenProjectId, "X");
Environment.SetEnvironmentVariable(KeenConstants.KeenMasterKey, "X");
Environment.SetEnvironmentVariable(KeenConstants.KeenWriteKey, "X");
Environment.SetEnvironmentVariable(KeenConstants.KeenReadKey, "X");

try
{
Environment.SetEnvironmentVariable("KEEN_PROJECT_ID", "X");
Environment.SetEnvironmentVariable("KEEN_MASTER_KEY", "X");
Environment.SetEnvironmentVariable("KEEN_WRITE_KEY", "X");
Environment.SetEnvironmentVariable("KEEN_READ_KEY", "X");
var settings = new ProjectSettingsProviderEnv();
Assert.DoesNotThrow(() => new KeenClient(settings));
}

var settings = new ProjectSettingsProviderEnv();
Assert.DoesNotThrow(() => new KeenClient(settings));
}
finally
{
Environment.SetEnvironmentVariable("KEEN_PROJECT_ID", ProjectId);
Environment.SetEnvironmentVariable("KEEN_MASTER_KEY", MasterKey);
Environment.SetEnvironmentVariable("KEEN_WRITE_KEY", WriteKey);
Environment.SetEnvironmentVariable("KEEN_READ_KEY", ReadKey);
}
[Test]
public void SettingsProviderEnv_VarsSet_SettingsAreCorrect()
{
var projectId = "projectId";
var masterKey = "masterKey";
var writeKey = "writeKey";
var readKey = "readKey";

Environment.SetEnvironmentVariable(KeenConstants.KeenProjectId, projectId);
Environment.SetEnvironmentVariable(KeenConstants.KeenMasterKey, masterKey);
Environment.SetEnvironmentVariable(KeenConstants.KeenWriteKey, writeKey);
Environment.SetEnvironmentVariable(KeenConstants.KeenReadKey, readKey);

var settings = new ProjectSettingsProviderEnv();
Assert.AreEqual(settings.ProjectId, projectId, "Project id wasn't properly set");
Assert.AreEqual(settings.MasterKey, masterKey, "Master key wasn't properly set");
Assert.AreEqual(settings.WriteKey, writeKey, "Write key wasn't properly set");
Assert.AreEqual(settings.ReadKey, readKey, "Read key wasn't properly set");
}

[Test]
Expand Down
Loading

0 comments on commit b820c2e

Please sign in to comment.