Skip to content

Commit

Permalink
Merge pull request #26 from JGrzybowski/HVAC-23
Browse files Browse the repository at this point in the history
HVAC-23 Symulacja upływu czasu z kontrolą prędkości
Closes #23
  • Loading branch information
JGrzybowski authored Jan 7, 2017
2 parents 7e7ab1d + b763069 commit f8f97bb
Show file tree
Hide file tree
Showing 49 changed files with 1,095 additions and 40 deletions.
10 changes: 9 additions & 1 deletion OfficeHVAC.Applications.RoomSimulator/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
3 changes: 3 additions & 0 deletions OfficeHVAC.Applications.RoomSimulator/Bootstraper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Autofac;
using OfficeHVAC.Modules.RoomSimulator;
using OfficeHVAC.Modules.TimeSimulation;
using Prism.Autofac;
using Prism.Modularity;
using System.Windows;
Expand All @@ -13,6 +14,7 @@ protected override void ConfigureContainerBuilder(ContainerBuilder containerBuil
{
base.ConfigureContainerBuilder(containerBuilder);

TimeSimulationModule.InitializeDependencies(containerBuilder);
RoomSimulatorModule.InitializeDependencies(containerBuilder);
}

Expand All @@ -32,6 +34,7 @@ protected override void InitializeShell()
protected override void ConfigureModuleCatalog()
{
ModuleCatalog catalog = (ModuleCatalog)ModuleCatalog;
catalog.AddModule(typeof(TimeSimulationModule));
catalog.AddModule(typeof(RoomSimulatorModule));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<HintPath>..\packages\Akka.Remote.1.1.2\lib\net45\Akka.Remote.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
<Reference Include="Autofac, Version=4.2.1.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.4.2.1\lib\net45\Autofac.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Google.ProtocolBuffers, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
Expand Down Expand Up @@ -172,6 +172,10 @@
<Project>{584598C9-E1CD-4592-9A88-24F34D23D282}</Project>
<Name>OfficeHVAC.Models</Name>
</ProjectReference>
<ProjectReference Include="..\OfficeHVAC.Modules.TimeSimulation\OfficeHVAC.Modules.TimeSimulation.csproj">
<Project>{641B89A7-EC7A-480F-858E-93B40A7C9197}</Project>
<Name>OfficeHVAC.Modules.TimeSimulation</Name>
</ProjectReference>
<ProjectReference Include="..\OfficeHVAC.Simulators\OfficeHVAC.Simulators.csproj">
<Project>{0B83EBD2-2C92-4B9B-B1CE-45C96F6C453B}</Project>
<Name>OfficeHVAC.Simulators</Name>
Expand Down
2 changes: 1 addition & 1 deletion OfficeHVAC.Applications.RoomSimulator/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Akka" version="1.1.2" targetFramework="net452" />
<package id="Akka.Remote" version="1.1.2" targetFramework="net452" />
<package id="Autofac" version="3.5.2" targetFramework="net452" />
<package id="Autofac" version="4.2.1" targetFramework="net452" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net452" />
<package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net452" />
<package id="Helios" version="2.1.2" targetFramework="net452" />
Expand Down
4 changes: 4 additions & 0 deletions OfficeHVAC.Factories.Tests/OfficeHVAC.Factories.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.2\lib\net35-Client\NodaTime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NSubstitute">
<HintPath>..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll</HintPath>
</Reference>
Expand Down
1 change: 1 addition & 0 deletions OfficeHVAC.Factories.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<packages>
<package id="Akka" version="1.1.2" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="NodaTime" version="1.3.2" targetFramework="net452" />
<package id="Prism.Core" version="6.2.0" targetFramework="net452" />
<package id="Shouldly" version="2.8.2" targetFramework="net452" />
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net452" />
Expand Down
4 changes: 4 additions & 0 deletions OfficeHVAC.Factories/OfficeHVAC.Factories.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.2\lib\net35-Client\NodaTime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Prism, Version=6.2.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Core.6.2.0\lib\net45\Prism.dll</HintPath>
<Private>True</Private>
Expand Down
1 change: 1 addition & 0 deletions OfficeHVAC.Factories/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<packages>
<package id="Akka" version="1.1.2" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="NodaTime" version="1.3.2" targetFramework="net452" />
<package id="Prism.Core" version="6.2.0" targetFramework="net452" />
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net452" />
</packages>
1 change: 1 addition & 0 deletions OfficeHVAC.Models.Tests/OfficeHVAC.Models.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
Expand Down
7 changes: 2 additions & 5 deletions OfficeHVAC.Models/ITimeSource.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using NodaTime;

namespace OfficeHVAC.Models
{
public interface ITimeSource
{
DateTime Now { get; }
}
public interface ITimeSource : IClock { }
}
12 changes: 11 additions & 1 deletion OfficeHVAC.Models/OfficeHVAC.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.2\lib\net35-Client\NodaTime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NodaTime.Testing, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.Testing.1.3.2\lib\net35-Client\NodaTime.Testing.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -49,11 +57,13 @@
<Compile Include="Devices\IDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RandomValueGenerator.cs" />
<Compile Include="RealTimeSource.cs" />
<Compile Include="Room.cs" />
<Compile Include="Sensor.cs" />
<Compile Include="SensorTypes.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<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.
Expand Down
9 changes: 0 additions & 9 deletions OfficeHVAC.Models/RealTimeSource.cs

This file was deleted.

5 changes: 5 additions & 0 deletions OfficeHVAC.Models/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NodaTime" version="1.3.2" targetFramework="net452" />
<package id="NodaTime.Testing" version="1.3.2" targetFramework="net452" />
</packages>
4 changes: 4 additions & 0 deletions OfficeHVAC.Modules.RoomSimulator.Tests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<assemblyIdentity name="xunit.assert" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.3402" newVersion="2.2.0.3402" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<HintPath>..\packages\Akka.Remote.1.1.2\lib\net45\Akka.Remote.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
<Reference Include="Autofac, Version=4.2.1.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.4.2.1\lib\net45\Autofac.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Google.ProtocolBuffers, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
Expand Down Expand Up @@ -116,6 +116,7 @@
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions OfficeHVAC.Modules.RoomSimulator/RoomSimulatorModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using OfficeHVAC.Factories.ActorPaths;
using OfficeHVAC.Factories.Configs;
using OfficeHVAC.Factories.Simulators.Temperature;
using OfficeHVAC.Models;
using OfficeHVAC.Modules.RoomSimulator.Factories;
using OfficeHVAC.Modules.RoomSimulator.ViewModels;
using Prism.Regions;
Expand All @@ -17,11 +16,9 @@ public class RoomSimulatorModule : Module, Prism.Modularity.IModule
//TODO: 07. Implement the module constructor to bring in required objects.
// When Prism loads the module it will instantiate this class using
// Autofac DI, Autofac will then inject a Region Manager instance.
public RoomSimulatorModule(IRegionManager regionManager, ContainerBuilder containerBuilder)
public RoomSimulatorModule(IRegionManager regionManager)
{
_regionManager = regionManager;

InitializeDependencies(containerBuilder);
}

//TODO: 08. Implement the required Initialize method to provide an entry point
Expand All @@ -35,7 +32,6 @@ public void Initialize()

public static void InitializeDependencies (ContainerBuilder containerBuilder)
{
containerBuilder.RegisterType<RealTimeSource>().As<ITimeSource>();
containerBuilder.RegisterType<RoomSimulatorModule>();
containerBuilder.RegisterType<RemoteConfigBuilder>().As<IConfigBuilder>();
containerBuilder.RegisterType<RemoteActorPathBuilder>()
Expand Down
11 changes: 11 additions & 0 deletions OfficeHVAC.Modules.RoomSimulator/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
2 changes: 1 addition & 1 deletion OfficeHVAC.Modules.RoomSimulator/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Akka" version="1.1.2" targetFramework="net452" />
<package id="Akka.Remote" version="1.1.2" targetFramework="net452" />
<package id="Autofac" version="3.5.2" targetFramework="net452" />
<package id="Autofac" version="4.2.1" targetFramework="net452" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net452" />
<package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net452" />
<package id="Helios" version="2.1.2" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using NodaTime;
using Shouldly;
using Xunit;

namespace OfficeHVAC.Modules.TimeSimulation.Tests.ControlledTimeSource
{
public class AddXYZ
{
private static readonly Instant InitialTime = Instant.FromUtc(2000, 12, 01, 12, 00, 00);

[Fact]
public void can_change_time_in_hours()
{
//Arrange
var clock = new TimeSources.ControlledTimeSource(InitialTime);

//Act
clock.AddHours(3);

//Assert
clock.Now.ShouldBe(InitialTime + Duration.FromHours(3));
}

[Fact]
public void can_change_time_in_minutes()
{
//Arrange
var clock = new TimeSources.ControlledTimeSource(InitialTime);

//Act
clock.AddMinutes(3);

//Assert
clock.Now.ShouldBe(InitialTime + Duration.FromMinutes(3));
}

[Fact]
public void can_change_time_in_seconds()
{
//Arrange
var clock = new TimeSources.ControlledTimeSource(InitialTime);

//Act
clock.AddSeconds(3);

//Assert
clock.Now.ShouldBe(InitialTime + Duration.FromSeconds(3));
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NodaTime;
using Shouldly;
using Xunit;

namespace OfficeHVAC.Modules.TimeSimulation.Tests.ControlledTimeSource
{
public class Constructor
{
private static readonly Instant InitialTime = Instant.FromUtc(2000, 12, 01, 12, 00, 00);

[Fact]
public void returns_initial_time_after_being_constructed()
{
//Arrange
var clock = new TimeSources.ControlledTimeSource(InitialTime);

//Assert
clock.Now.ShouldBe(InitialTime);
}

[Fact]
public void sets_initial_speed_to_1()
{
//Arrange
var clock = new TimeSources.ControlledTimeSource(InitialTime);

//Assert
clock.Speed.ShouldBe(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using NodaTime;
using Shouldly;
using Xunit;

namespace OfficeHVAC.Modules.TimeSimulation.Tests.ControlledTimeSource
{
public class Reset
{
private static readonly Instant InitialTime = Instant.FromUtc(2000, 12, 01, 12, 00, 00);

[Fact]
public void sets_new_value_of_Now()
{
//Arrange
var clock = new TimeSources.ControlledTimeSource(InitialTime);
var newInstant = InitialTime - Duration.FromHours(-15);

//Act
clock.Reset(newInstant);

//Assert
clock.Now.ShouldBe(newInstant);
}
}

}
Loading

0 comments on commit f8f97bb

Please sign in to comment.