Skip to content

More build fixes #76

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

Open
wants to merge 3 commits 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
4 changes: 2 additions & 2 deletions src/unBand.CargoClientExtender/BluetoothDeviceTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BluetoothDeviceTransport : IDeviceTransport, IDisposable
private bool _disposed;

public CargoStreamReader CargoReader { get; private set; }
public Stream CargoStream { get; private set; }
public ICargoStream CargoStream { get; private set; }
public CargoStreamWriter CargoWriter { get; private set; }
public bool IsConnected { get; private set; }
public int MaxDataPayloadSize { get; private set; }
Expand All @@ -48,7 +48,7 @@ public async Task ConnectAsync(ushort maxConnectAttempts = 1)

if (deviceService == null)
{
throw new Exception("Failed to create RfcommDeviceService with id: " + _deviceInfo.Id.ToString());
throw new Exception("Failed to create RfcommDeviceService with name: " + _deviceInfo.Name.ToString());
}

var streamSocket = new StreamSocket();
Expand Down
9 changes: 8 additions & 1 deletion src/unBand.CargoClientExtender/BluetoothStreamWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
using System.Threading;
using System.Threading.Tasks;
using Windows.Networking.Sockets;
using Microsoft.Band;

namespace unBand.CargoClientExtender
{
/// <summary>
/// Small StreamSocket wrapper (really around Stream, but implemented on top of a StreamSocket)
/// that implemented Read/Write Timeouts
/// </summary>
internal class BluetoothStreamWrapper : Stream
internal class BluetoothStreamWrapper : Stream, ICargoStream
{
const int DEFAULT_WRITE_TIMEOUT = 1000;
const int DEFAULT_READ_TIMEOUT = 1000;
Expand All @@ -33,6 +34,12 @@ internal class BluetoothStreamWrapper : Stream
public override int ReadTimeout { get; set; }
public override int WriteTimeout { get; set; }

public CancellationToken Cancel
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}

public override long Length { get { throw new NotImplementedException(); } }

public override long Position
Expand Down
18 changes: 10 additions & 8 deletions src/unBand.CargoClientExtender/unBand.CargoClientExtender.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,28 @@
<TargetPlatformVersion>8.1</TargetPlatformVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Band.Admin.Desktop.unband">
<HintPath>..\Microsoft.Band.Admin.Desktop.unband.dll</HintPath>
<Reference Include="Microsoft.Band">
<HintPath>..\Microsoft.Band.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Band.Admin.unband">
<HintPath>..\Microsoft.Band.Admin.unband.dll</HintPath>
<Reference Include="Microsoft.Band.Admin">
<HintPath>..\Microsoft.Band.Admin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Band.Desktop.unband">
<HintPath>..\Microsoft.Band.Desktop.unband.dll</HintPath>
<Reference Include="Microsoft.Band.Admin.Desktop">
<HintPath>..\Microsoft.Band.Admin.Desktop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Band.unband">
<HintPath>..\Microsoft.Band.unband.dll</HintPath>
<Reference Include="Microsoft.Band.Desktop">
<HintPath>..\Microsoft.Band.Desktop.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.InteropServices.WindowsRuntime" />
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
58 changes: 58 additions & 0 deletions src/unBand.Cloud.Tests/BandMapPointCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ploeh.AutoFixture;
using unBand.Cloud.Events;

namespace unBand.Cloud.Tests
{
[TestClass]
public class BandMapPointCollectionTests
{
private IFixture _fixture;
private BandMapPointCollection _subjectUnderTest;

[TestInitialize]
public void SetUp()
{
_fixture = new Fixture();
}

[TestMethod]
public void FiltersInvalidBeginMiddleEndMapPointFromCollection()
{
DoTest(3, 0);
DoTest(3, 1);
DoTest(3, 2);
}

private void DoTest(int collectionSize, int indexOfInvalidMapPoint)
{
_subjectUnderTest = new BandMapPointCollection();
var mapPoints = CreateTestData(collectionSize);
MakeInvalid(mapPoints[indexOfInvalidMapPoint]);
PopulateCollection(mapPoints);

Assert.AreEqual(_subjectUnderTest.Count(), collectionSize - 1);
Assert.IsFalse(_subjectUnderTest.Contains(mapPoints[indexOfInvalidMapPoint]));
}

private List<BandMapPoint> CreateTestData(int repeatCount)
{
_fixture.RepeatCount = repeatCount;
return _fixture.CreateMany<BandMapPoint>().ToList();
}

private void PopulateCollection(List<BandMapPoint> data)
{
data.ForEach(x => _subjectUnderTest.Add(x));
}

private void MakeInvalid(BandMapPoint subject)
{
subject.Latitude = 0.0;
subject.Longitude = 0.0;
subject.Altitude = 0.0;
}
}
}
36 changes: 36 additions & 0 deletions src/unBand.Cloud.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("unBand.Cloud.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("unBand.Cloud.Tests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b184addb-a2f1-422f-912f-05e57f3d83be")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 4 additions & 0 deletions src/unBand.Cloud.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoFixture" version="3.30.3" targetFramework="net45" />
</packages>
96 changes: 96 additions & 0 deletions src/unBand.Cloud.Tests/unBand.Cloud.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{32DEEBC3-DB59-4D5C-AE4B-FB7CE2E96B41}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>unBand.Cloud.Tests</RootNamespace>
<AssemblyName>unBand.Cloud.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.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>
</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="Ploeh.AutoFixture, Version=3.30.3.0, Culture=neutral, PublicKeyToken=b24654c590009d4f, processorArchitecture=MSIL">
<HintPath>..\packages\AutoFixture.3.30.3\lib\net40\Ploeh.AutoFixture.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="BandMapPointCollectionTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\unBand.Cloud\unBand.Cloud.csproj">
<Project>{c65bd296-f5e1-400e-886e-bc3def6476ef}</Project>
<Name>unBand.Cloud</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
41 changes: 41 additions & 0 deletions src/unBand.Cloud/Events/BandMapPointCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace unBand.Cloud.Events
{
internal class BandMapPointCollection : IEnumerable<BandMapPoint>
{
private readonly List<BandMapPoint> _mapPoints = new List<BandMapPoint>();

internal void Add(BandMapPoint mapPoint)
{
_mapPoints.Add(mapPoint);
}

public IEnumerator<BandMapPoint> GetEnumerator()
{
return _mapPoints.FilterInvalidCoordinates().GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}

internal static class BandMapPointFilterExtensions
{
public static IEnumerable<BandMapPoint> FilterInvalidCoordinates(this IEnumerable<BandMapPoint> self)
{
return self.Where(IsValid);
}

private static bool IsValid(BandMapPoint point)
{
return !((int) point.Latitude == 0 &&
(int) point.Longitude == 0 &&
(int) point.Altitude == 0);
}
}
}
11 changes: 5 additions & 6 deletions src/unBand.Cloud/Events/BikeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using unBand.Cloud.Events;
using unBand.Cloud.Exporters.EventExporters;

namespace unBand.Cloud
Expand Down Expand Up @@ -47,7 +48,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, System.Global
[TypeConverter(typeof(BikeEventConverter))]
public class BikeEvent : BandExerciseEventBase, IBandEventWithMapPoints
{

private readonly BandMapPointCollection _mapPoints = new BandMapPointCollection();
private static List<IEventExporter> _exporters;

public override List<IEventExporter> Exporters
Expand All @@ -69,7 +70,7 @@ public override BandEventExpandType[] Expanders
get { return new BandEventExpandType[] { BandEventExpandType.Info, BandEventExpandType.Sequences, BandEventExpandType.MapPoints }; }
}

public List<BandMapPoint> MapPoints { get; private set; }
public IEnumerable<BandMapPoint> MapPoints { get{return _mapPoints;} }

/// <summary>
/// Calculated property which indicates whether or not any actual GPS points were
Expand All @@ -86,9 +87,7 @@ public override BandEventExpandType[] Expanders
public int Pace { get; set; }

public BikeEvent(JObject json) : base(json)
{
MapPoints = new List<BandMapPoint>();

{
dynamic eventSummary = (dynamic)json;

TotalDistance = eventSummary.TotalDistance;
Expand Down Expand Up @@ -146,7 +145,7 @@ public override void InitFullEventData(JObject json)
HasGPSPoints = true;
}

MapPoints.Add(runMapPoint);
_mapPoints.Add(runMapPoint);
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/unBand.Cloud/Events/IBandEventWithMapPoints.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using unBand.Cloud.Events;

namespace unBand.Cloud
{
public interface IBandEventWithMapPoints
{
bool HasGPSPoints { get; set; }

List<BandMapPoint> MapPoints { get; }
IEnumerable<BandMapPoint> MapPoints { get; }
}
}
}
Loading