Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
Namespace change
Browse files Browse the repository at this point in the history
  • Loading branch information
mannkind committed Oct 24, 2020
1 parent 86e1572 commit bd2e84f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion SeattleWaste/DataAccess/SourceDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Newtonsoft.Json;
using SeattleWaste.Models.Shared;
using SeattleWaste.Models.Source;
using TwoMQTT.Core.Interfaces;
using TwoMQTT.Interfaces;

namespace SeattleWaste.DataAccess
{
Expand Down
10 changes: 5 additions & 5 deletions SeattleWaste/Liasons/MQTTLiason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
using Microsoft.Extensions.Options;
using SeattleWaste.Models.Options;
using SeattleWaste.Models.Shared;
using TwoMQTT.Core;
using TwoMQTT.Core.Interfaces;
using TwoMQTT.Core.Liasons;
using TwoMQTT.Core.Models;
using TwoMQTT.Core.Utils;
using TwoMQTT;
using TwoMQTT.Interfaces;
using TwoMQTT.Liasons;
using TwoMQTT.Models;
using TwoMQTT.Utils;

namespace SeattleWaste.Liasons
{
Expand Down
31 changes: 13 additions & 18 deletions SeattleWaste/Liasons/SourceLiason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using SeattleWaste.Models.Options;
using SeattleWaste.Models.Shared;
using SeattleWaste.Models.Source;
using TwoMQTT.Core.Interfaces;
using TwoMQTT.Core.Liasons;
using TwoMQTT.Interfaces;
using TwoMQTT.Liasons;

namespace SeattleWaste.Liasons
{
Expand All @@ -33,23 +33,18 @@ public SourceLiason(ILogger<SourceLiason> logger, ISourceDAO sourceDAO,
protected override async Task<Resource?> FetchOneAsync(SlugMapping key, CancellationToken cancellationToken)
{
var result = await this.SourceDAO.FetchOneAsync(key, cancellationToken);
var resp = result != null ? this.MapData(result) : null;
return resp;
}

/// <summary>
/// Map the source response to a shared response representation.
/// </summary>
/// <param name="src"></param>
/// <returns></returns>
private Resource MapData(Response src) =>
new Resource
return result switch
{
Address = src.Address,
Start = src.Start,
Garbage = src.Garbage,
Recycling = src.Recycling,
FoodAndYardWaste = src.FoodAndYardWaste,
Response => new Resource
{
Address = result.Address,
Start = result.Start,
Garbage = result.Garbage,
Recycling = result.Recycling,
FoodAndYardWaste = result.FoodAndYardWaste,
},
_ => null,
};
}
}
}
2 changes: 1 addition & 1 deletion SeattleWaste/Models/Options/MQTTOpts.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TwoMQTT.Core.Models;
using TwoMQTT.Models;

namespace SeattleWaste.Models.Options
{
Expand Down
2 changes: 1 addition & 1 deletion SeattleWaste/Models/Options/SharedOpts.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using SeattleWaste.Models.Shared;
using TwoMQTT.Core.Interfaces;
using TwoMQTT.Interfaces;

namespace SeattleWaste.Models.Options
{
Expand Down
10 changes: 5 additions & 5 deletions SeattleWaste/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
using SeattleWaste.DataAccess;
using SeattleWaste.Liasons;
using SeattleWaste.Models.Shared;
using TwoMQTT.Core;
using TwoMQTT.Core.Extensions;
using TwoMQTT.Core.Interfaces;
using TwoMQTT.Core.Managers;
using TwoMQTT;
using TwoMQTT.Extensions;
using TwoMQTT.Interfaces;
using TwoMQTT.Managers;


namespace SeattleWaste
Expand Down Expand Up @@ -45,7 +45,7 @@ protected override IServiceCollection ConfigureServices(HostBuilderContext hostC
return services
.ConfigureOpts<Models.Options.SharedOpts>(hostContext, Models.Options.SharedOpts.Section)
.ConfigureOpts<Models.Options.SourceOpts>(hostContext, Models.Options.SourceOpts.Section)
.ConfigureOpts<TwoMQTT.Core.Models.MQTTManagerOptions>(hostContext, Models.Options.MQTTOpts.Section)
.ConfigureOpts<TwoMQTT.Models.MQTTManagerOptions>(hostContext, Models.Options.MQTTOpts.Section)
.AddSingleton<IThrottleManager, ThrottleManager>(x =>
{
var opts = x.GetService<IOptions<Models.Options.SourceOpts>>();
Expand Down
2 changes: 1 addition & 1 deletion SeattleWaste/SeattleWaste.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="twomqtt" Version="0.9.20292.3465-dev" />
<PackageReference Include="twomqtt" Version="0.9.20298.1453-dev" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions SeattleWasteTest/Liasons/MQTTLiasonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using TwoMQTT.Core.Utils;
using TwoMQTT.Utils;
using SeattleWaste.Liasons;
using SeattleWaste.Models.Options;
using SeattleWaste.Models.Shared;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void MapDataTest()
});

generator.Setup(x => x.BuildDiscovery(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<System.Reflection.AssemblyName>(), false))
.Returns(new TwoMQTT.Core.Models.MQTTDiscovery());
.Returns(new TwoMQTT.Models.MQTTDiscovery());
generator.Setup(x => x.StateTopic(test.Q.Slug, nameof(Resource.Start)))
.Returns($"totes/{test.Q.Slug}/topic/{nameof(Resource.Start)}");

Expand Down Expand Up @@ -78,7 +78,7 @@ public void DiscoveriesTest()
});

generator.Setup(x => x.BuildDiscovery(test.Q.Slug, nameof(Resource.Start), It.IsAny<System.Reflection.AssemblyName>(), false))
.Returns(new TwoMQTT.Core.Models.MQTTDiscovery());
.Returns(new TwoMQTT.Models.MQTTDiscovery());

var mqttLiason = new MQTTLiason(logger.Object, generator.Object, sharedOpts);
var results = mqttLiason.Discoveries();
Expand Down

0 comments on commit bd2e84f

Please sign in to comment.