Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/nuget/src/Microsoft.AspNetCore.Co…
Browse files Browse the repository at this point in the history
…mponents.WebAssembly.Server-6.0.2
  • Loading branch information
kbeaugrand authored Feb 9, 2022
2 parents c68a2f8 + d982c75 commit 8b28641
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using AzureIoTHub.Portal.Server.Services;
using Microsoft.Azure.Devices;
using Moq;
using NUnit.Framework;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace AzureIoTHub.Portal.Server.Tests.Services
{
[TestFixture]
public class ConfigsServicesTests
{
private MockRepository mockRepository;

private Mock<RegistryManager> mockRegistryManager;

[SetUp]
public void SetUp()
{
this.mockRepository = new MockRepository(MockBehavior.Strict);

this.mockRegistryManager = this.mockRepository.Create<RegistryManager>();
}

private ConfigsServices CreateConfigsServices()
{
return new ConfigsServices(this.mockRegistryManager.Object);
}

[Test]
public async Task GetAllConfigs_StateUnderTest_ExpectedBehavior()
{
// Arrange
var configsServices = this.CreateConfigsServices();
this.mockRegistryManager.Setup(c => c.GetConfigurationsAsync(It.Is<int>(x => x == 0)))
.ReturnsAsync(new[]
{
new Configuration("aaa"),
new Configuration("bbb")
});

// Act
var result = await configsServices.GetAllConfigs();

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual("aaa", result.First().Id);
this.mockRepository.VerifyAll();
}

[Test]
public async Task GetConfigItem_StateUnderTest_ExpectedBehavior()
{
// Arrange
var configsServices = this.CreateConfigsServices();
string id = "aaa";
this.mockRegistryManager.Setup(c => c.GetConfigurationAsync(It.Is<string>(x => x == id)))
.ReturnsAsync(new Configuration(id));

// Act
var result = await configsServices.GetConfigItem(id);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(id, result.Id);
this.mockRepository.VerifyAll();
}
}
}
18 changes: 0 additions & 18 deletions src/AzureIoTHub.Portal.Server.Tests/UnitTest1.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Blazored.Modal" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="MudBlazor" Version="6.0.6" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.Azure.Devices" Version="1.37.0" />
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.1" />
<PackageReference Include="Microsoft.Azure.Devices.Shared" Version="1.30.1" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.2" />
<PackageReference Include="Microsoft.Graph" Version="4.17.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="MudBlazor" Version="6.0.6" />
Expand Down

0 comments on commit 8b28641

Please sign in to comment.