Skip to content
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

Grand rework #105

Merged
merged 42 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
373761f
Migrate to .NET Core 3
Tyrrrz Sep 29, 2019
893e990
Rework UI
Tyrrrz Sep 29, 2019
9e2482e
Allow manual editing of temperatures
Tyrrrz Oct 3, 2019
7657af2
Update deployment script
Tyrrrz Oct 3, 2019
815953e
Refactor
Tyrrrz Oct 3, 2019
157b3c1
Add GeoLocation.TryParse
Tyrrrz Oct 4, 2019
4bef2ac
Allow manually specifying location
Tyrrrz Oct 4, 2019
c365a73
Split out hotkey settings in its own tab
Tyrrrz Oct 4, 2019
90a2e1e
Add auto start setting
Tyrrrz Oct 4, 2019
f91173d
Refactor
Tyrrrz Oct 5, 2019
67946ab
Add reset settings button
Tyrrrz Oct 5, 2019
538e698
Hide main window to tray if the app was launched automatically
Tyrrrz Oct 5, 2019
262be6e
Update appveyor image
Tyrrrz Oct 5, 2019
f6e52a0
Add "default to daytime temperature" setting
Tyrrrz Oct 5, 2019
ba76b9e
Unlock gamma range from the app
Tyrrrz Oct 5, 2019
5f76525
Fix inaccuracy in sunrise/sunset calculation due to timezones
Tyrrrz Oct 7, 2019
72f4595
Separate manual sunrise/sunset time from location-based calculation
Tyrrrz Oct 8, 2019
0af7042
Refactor astronomy to a separate class and add tests
Tyrrrz Oct 8, 2019
4b1007a
Update readme
Tyrrrz Oct 8, 2019
dca3cc0
Update deploy
Tyrrrz Oct 8, 2019
d8b7dff
Fix incorrect registry key path for gamma range
Tyrrrz Oct 9, 2019
429c9e8
Add autoupdate
Tyrrrz Oct 9, 2019
60cf7c4
Set some limitations in settings
Tyrrrz Oct 9, 2019
12e7209
Allow more precise configuration for transition duration, sunrise and…
Tyrrrz Oct 11, 2019
d29350d
Update readme
Tyrrrz Oct 11, 2019
57a7f28
Rework main screen to incorporate cycle state display
Tyrrrz Oct 19, 2019
942a8ea
Add proper save/cancel buttons to settings
Tyrrrz Oct 20, 2019
6c1d15e
Add support for brightness adjustments
Tyrrrz Oct 21, 2019
6e24b87
Remove some obsolete code
Tyrrrz Oct 23, 2019
fdef743
Bring the clock back to cycle display
Tyrrrz Oct 23, 2019
a18252a
Add About button to root view
Tyrrrz Oct 23, 2019
e7ece31
Remove gamma polling
Tyrrrz Oct 23, 2019
9df0921
Use hotkey editor control instead of viewmodel
Tyrrrz Oct 23, 2019
6ac9c92
Cleanup tray menu
Tyrrrz Oct 23, 2019
ed05c6b
Register hotkeys only on save
Tyrrrz Oct 23, 2019
425f9fe
Add basic error handling for resolving location
Tyrrrz Oct 23, 2019
c3506d7
Ensure timers don't trigger after disposing
Tyrrrz Oct 27, 2019
32b94ef
Fallback to command line when there are insufficicent permissions to …
Tyrrrz Oct 28, 2019
cb8a3fc
Register hotkeys at startup and simplify SettingsViewModel
Tyrrrz Oct 28, 2019
5a1c38a
Add some tests
Tyrrrz Oct 28, 2019
a33794c
Autoupdate shouldn't crash the app
Tyrrrz Oct 20, 2019
dbd7c23
Add test for TimeSpanToHumanizedDurationStringConverter
Tyrrrz Oct 21, 2019
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
26 changes: 0 additions & 26 deletions Deploy/Choco/lightbulb.nuspec

This file was deleted.

10 changes: 0 additions & 10 deletions Deploy/Choco/tools/chocolateyinstall.ps1

This file was deleted.

50 changes: 0 additions & 50 deletions Deploy/Installer/Installer.iss

This file was deleted.

2 changes: 0 additions & 2 deletions Deploy/Portable/LightBulb_Portable.bat

This file was deleted.

6 changes: 0 additions & 6 deletions Deploy/Portable/LightBulb_Portable_Readme.txt

This file was deleted.

4 changes: 0 additions & 4 deletions Deploy/Portable/Manual_Gamma_Registry_Fix.reg

This file was deleted.

31 changes: 15 additions & 16 deletions Deploy/Prepare.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# --- INSTALLER ---
$licenseFilePath = "$PSScriptRoot/../License.txt"

# Run Inno Setup Compiler
& "c:\Program Files (x86)\Inno Setup 5\iscc" "$PSScriptRoot\Installer\Installer.iss"
$projectDirPath = "$PSScriptRoot/../LightBulb"
$publishDirPath = "$PSScriptRoot/bin/build/"
$artifactFilePath = "$PSScriptRoot/bin/LightBulb.zip"

# --- PORTABLE ---
# Prepare directory
if (Test-Path $publishDirPath) {
Remove-Item $publishDirPath -Recurse -Force
}
New-Item $publishDirPath -ItemType Directory -Force

# Build & publish
dotnet publish $projectDirPath -o $publishDirPath -c Release | Out-Host

# Get files
$files = @()
$files += Get-Item -Path "$PSScriptRoot\..\License.txt"
$files += Get-ChildItem -Path "$PSScriptRoot\..\LightBulb\bin\Release\*" -Include "*.exe", "*.dll", "*.config"
$files += Get-ChildItem -Path "$PSScriptRoot\Portable\*";
$files += Get-Item -Path $licenseFilePath
$files += Get-ChildItem -Path $publishDirPath

# Pack into archive
New-Item "$PSScriptRoot\Portable\bin" -ItemType Directory -Force
$files | Compress-Archive -DestinationPath "$PSScriptRoot\Portable\bin\LightBulb-Portable.zip" -Force

# --- CHOCOLATEY ---

# Create package
New-Item "$PSScriptRoot\Choco\bin\" -ItemType Directory -Force
choco pack $PSScriptRoot\Choco\lightbulb.nuspec --out $PSScriptRoot\Choco\bin\
$files | Compress-Archive -DestinationPath $artifactFilePath -Force
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using LightBulb.Converters;
using NUnit.Framework;

namespace LightBulb.Tests.Converters
{
[TestFixture]
public class TimeSpanToHumanizedDurationStringConverterTests
{
private static IEnumerable<TestCaseData> GetTestCases_Convert()
{
yield return new TestCaseData(
TimeSpan.FromHours(1),
"1 hour",
null
);

yield return new TestCaseData(
TimeSpan.FromHours(2),
"2 hours",
null
);

yield return new TestCaseData(
TimeSpan.FromHours(1.5),
"1 hour 30 minutes",
null
);

yield return new TestCaseData(
TimeSpan.FromHours(4.5),
"4 hours 30 minutes",
null
);

yield return new TestCaseData(
TimeSpan.FromHours(1) + TimeSpan.FromMinutes(1),
"1 hour 1 minute",
null
);

yield return new TestCaseData(
TimeSpan.FromHours(2) + TimeSpan.FromMinutes(1),
"2 hours 1 minute",
null
);

yield return new TestCaseData(
TimeSpan.FromHours(2) + TimeSpan.FromMinutes(10) + TimeSpan.FromSeconds(15),
"2 hours 10 minutes",
null
);

yield return new TestCaseData(
TimeSpan.FromSeconds(10),
"10 seconds",
null
);

yield return new TestCaseData(
TimeSpan.FromSeconds(1),
"1 second",
null
);

yield return new TestCaseData(
TimeSpan.FromSeconds(0),
"0 seconds",
null
);

yield return new TestCaseData(
TimeSpan.Zero,
"0 seconds",
null
);
}

[Test]
[TestCaseSource(nameof(GetTestCases_Convert))]
public void Convert_Test(TimeSpan input, string expectedOutput, CultureInfo cultureInfo)
{
// Arrange
var converter = new TimeSpanToHumanizedDurationStringConverter();

// Act
var output = converter.Convert(input, expectedOutput.GetType(), null, cultureInfo);

// Assert
Assert.That(output, Is.EqualTo(expectedOutput));
}
}
}
88 changes: 88 additions & 0 deletions LightBulb.Tests/Helpers/AstronomyTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using LightBulb.Helpers;
using LightBulb.Models;
using NUnit.Framework;

namespace LightBulb.Tests.Helpers
{
[TestFixture]
public class AstronomyTests
{
private static IEnumerable<TestCaseData> GetTestCases_CalculateSunrise()
{
yield return new TestCaseData(
new GeoLocation(40.7128, -74.0060),
new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(-4)),
new TimeSpan(07, 01, 00)
);

yield return new TestCaseData(
new GeoLocation(40.7128, -74.0060),
new DateTimeOffset(2019, 10, 08, 13, 37, 59, TimeSpan.FromHours(-4)),
new TimeSpan(07, 01, 00)
);

yield return new TestCaseData(
new GeoLocation(55.6761, 12.5683),
new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(+2)),
new TimeSpan(07, 27, 00)
);

yield return new TestCaseData(
new GeoLocation(55.6761, 12.5683),
new DateTimeOffset(2019, 10, 08, 05, 41, 01, TimeSpan.FromHours(+2)),
new TimeSpan(07, 27, 00)
);
}

[Test]
[TestCaseSource(nameof(GetTestCases_CalculateSunrise))]
public void CalculateSunrise_Test(GeoLocation location, DateTimeOffset instant, TimeSpan expectedSunriseTime)
{
// Act
var sunriseTime = Astronomy.CalculateSunrise(location, instant).TimeOfDay;

// Assert
Assert.That(sunriseTime, Is.EqualTo(expectedSunriseTime).Within(TimeSpan.FromMinutes(3)));
}

private static IEnumerable<TestCaseData> GetTestCases_CalculateSunset()
{
yield return new TestCaseData(
new GeoLocation(40.7128, -74.0060),
new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(-4)),
new TimeSpan(18, 27, 00)
);

yield return new TestCaseData(
new GeoLocation(40.7128, -74.0060),
new DateTimeOffset(2019, 10, 08, 13, 37, 59, TimeSpan.FromHours(-4)),
new TimeSpan(18, 27, 00)
);

yield return new TestCaseData(
new GeoLocation(35.6762, 139.6503),
new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(+9)),
new TimeSpan(17, 15, 00)
);

yield return new TestCaseData(
new GeoLocation(35.6762, 139.6503),
new DateTimeOffset(2019, 10, 08, 23, 59, 59, TimeSpan.FromHours(+9)),
new TimeSpan(17, 15, 00)
);
}

[Test]
[TestCaseSource(nameof(GetTestCases_CalculateSunset))]
public void CalculateSunset_Test(GeoLocation location, DateTimeOffset instant, TimeSpan expectedSunsetTime)
{
// Act
var sunsetTime = Astronomy.CalculateSunset(location, instant).TimeOfDay;

// Assert
Assert.That(sunsetTime, Is.EqualTo(expectedSunsetTime).Within(TimeSpan.FromMinutes(3)));
}
}
}
19 changes: 19 additions & 0 deletions LightBulb.Tests/LightBulb.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
</ItemGroup>

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

</Project>
Loading