Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 5.0.x
- name: Restore packages
run: dotnet restore src
- name: Test
Expand All @@ -47,7 +47,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 5.0.x
- name: Restore packages
run: dotnet restore src
- name: Build and create package nuget
Expand Down
4 changes: 2 additions & 2 deletions src/Netatmo.Tests/AirClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace Netatmo.Tests
{
public class AirClient : IDisposable
{
private readonly HttpTest httpTest;

public AirClient()
{
httpTest = new HttpTest();
Expand All @@ -24,8 +26,6 @@ public void Dispose()
httpTest.Dispose();
}

private readonly HttpTest httpTest;

[Fact]
public async Task GetStationsData_Should_Return_DataResponse_With_AirData()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,13 @@ public class GetRoomMeasureArgumentExceptionData : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
{
yield return new object[] {new GetRoomMeasureParameters(), "Home Id shouldn't be null"};
yield return new object[] { new GetRoomMeasureParameters(), "Home Id shouldn't be null" };
yield return new object[] { new GetRoomMeasureParameters { HomeId = "5a327cbdb05a2133678b5d3e" }, "Room Id shouldn't be null" };
yield return new object[] { new GetRoomMeasureParameters { HomeId = "5a327cbdb05a2133678b5d3e", RoomId = "2255031728" }, "Scale shouldn't be null" };
yield return new object[] { new GetRoomMeasureParameters { HomeId = "5a327cbdb05a2133678b5d3e", RoomId = "2255031728", Scale = Scale.Max }, "Type shouldn't be null" };
yield return new object[]
{
new GetRoomMeasureParameters
{
HomeId = "5a327cbdb05a2133678b5d3e"
},
"Room Id shouldn't be null"
};
yield return new object[]
{
new GetRoomMeasureParameters
{
HomeId = "5a327cbdb05a2133678b5d3e",
RoomId = "2255031728"
},
"Scale shouldn't be null"
};
yield return new object[]
{
new GetRoomMeasureParameters
{
HomeId = "5a327cbdb05a2133678b5d3e",
RoomId = "2255031728",
Scale = Scale.Max
},
"Type shouldn't be null"
};
yield return new object[]
{
new GetRoomMeasureParameters
{
HomeId = "5a327cbdb05a2133678b5d3e",
RoomId = "2255031728",
Scale = Scale.Max,
Type = ThermostatMeasurementType.DateMinTemp
},
new GetRoomMeasureParameters { HomeId = "5a327cbdb05a2133678b5d3e", RoomId = "2255031728", Scale = Scale.Max, Type = ThermostatMeasurementType.DateMinTemp },
"Type shouldn't be allow for this scale"
};
yield return new object[]
Expand Down Expand Up @@ -88,9 +58,6 @@ public IEnumerator<object[]> GetEnumerator()
};
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
43 changes: 12 additions & 31 deletions src/Netatmo.Tests/CredentialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Netatmo.Tests
{
public class CredentialManager : IDisposable
{
private readonly HttpTest httpTest;

public CredentialManager()
{
httpTest = new HttpTest();
Expand All @@ -22,17 +24,10 @@ public void Dispose()
httpTest.Dispose();
}

private readonly HttpTest httpTest;

[Fact]
public async Task GenerateToken_Should_Acquire_Excepted_CredentialToken()
{
var expectedToken = new
{
access_token = "2YotnFZFEjr1zCsicMWpAA",
expires_in = 10800,
refresh_token = "tGzv3JOkF0XG5Qx2TlKWIA"
};
var expectedToken = new { access_token = "2YotnFZFEjr1zCsicMWpAA", expires_in = 10800, refresh_token = "tGzv3JOkF0XG5Qx2TlKWIA" };

httpTest.RespondWithJson(expectedToken);

Expand All @@ -41,8 +36,8 @@ public async Task GenerateToken_Should_Acquire_Excepted_CredentialToken()
await sut.GenerateToken("[email protected]", "p@$$W0rd",
new[]
{
Scope.CameraAccess, Scope.CameraRead, Scope.CameraWrite, Scope.HomecoachRead, Scope.PresenceAccess, Scope.PresenceRead,
Scope.StationRead, Scope.StationWrite, Scope.ThermostatRead
Scope.CameraAccess, Scope.CameraRead, Scope.CameraWrite, Scope.HomecoachRead, Scope.PresenceAccess, Scope.PresenceRead, Scope.StationRead,
Scope.StationWrite, Scope.ThermostatRead
});

var token = sut.CredentialToken;
Expand All @@ -59,16 +54,12 @@ await sut.GenerateToken("[email protected]", "p@$$W0rd",
token.AccessToken.Should().Be(expectedToken.access_token);
token.RefreshToken.Should().Be(expectedToken.refresh_token);
token.ExpiresAt.Should().Be(token.ReceivedAt.Plus(Duration.FromSeconds(expectedToken.expires_in)));
}
}

[Fact]
public void ProvideOAuth2Token_Should_Provide_Token_From_Existing()
{
var expectedToken = new
{
access_token = "2YotnFZFEjr1zCsicMWpAA",
expires_in = 20
};
var expectedToken = new { access_token = "2YotnFZFEjr1zCsicMWpAA", expires_in = 20 };

httpTest.RespondWithJson(expectedToken);

Expand All @@ -87,19 +78,9 @@ public void ProvideOAuth2Token_Should_Provide_Token_From_Existing()
[Fact]
public async Task RefreshToken_Should_Refresh_Token()
{
var token = new
{
access_token = "2YotnFZFEjr1zCsicMWpAA",
expires_in = 10800,
refresh_token = "tGzv3JOkF0XG5Qx2TlKWIA"
};

var expectedToken = new
{
access_token = "dGVzdGNsaWVudDpzZWNyZXQ",
expires_in = 10800,
refresh_token = "fdb8fdbecf1d03ce5e6125c067733c0d51de209c"
};
var token = new { access_token = "2YotnFZFEjr1zCsicMWpAA", expires_in = 10800, refresh_token = "tGzv3JOkF0XG5Qx2TlKWIA" };

var expectedToken = new { access_token = "dGVzdGNsaWVudDpzZWNyZXQ", expires_in = 10800, refresh_token = "fdb8fdbecf1d03ce5e6125c067733c0d51de209c" };

httpTest.RespondWithJson(token);
httpTest.RespondWithJson(expectedToken);
Expand Down Expand Up @@ -128,4 +109,4 @@ public async Task RefreshToken_Should_Refresh_Token()
refreshedToken.Should().NotBe(oldToken);
}
}
}
}
Loading