Skip to content

Commit 15b4981

Browse files
authored
Resolve platform warnings (#5798)
* Installation Repository tests * Formatting * Remove extra LastActivityDate property * Remove exclusion
1 parent 0075a15 commit 15b4981

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

src/Core/Core.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@
7575
<Folder Include="Resources\" />
7676
<Folder Include="Properties\" />
7777
</ItemGroup>
78+
79+
<ItemGroup>
80+
<InternalsVisibleTo Include="Infrastructure.IntegrationTest" />
81+
</ItemGroup>
7882
</Project>

src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<!-- Temp exclusions until warnings are fixed -->
5-
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0108</WarningsNotAsErrors>
6-
</PropertyGroup>
7-
83
<ItemGroup>
94
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
105
<PackageReference Include="linq2db" Version="5.4.1" />

src/Infrastructure.EntityFramework/Platform/Installations/Models/Installation.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@
33

44
namespace Bit.Infrastructure.EntityFramework.Platform;
55

6-
public class Installation : C.Installation
7-
{
8-
// Shadow property - to be introduced by https://bitwarden.atlassian.net/browse/PM-11129
9-
// This isn't a value or entity used by self hosted servers, but it's
10-
// being added for synchronicity between database provider options.
11-
public DateTime? LastActivityDate { get; set; }
12-
}
6+
public class Installation : C.Installation;
137

148
public class InstallationMapperProfile : Profile
159
{
1610
public InstallationMapperProfile()
1711
{
18-
CreateMap<C.Installation, Installation>()
19-
// Shadow property - to be introduced by https://bitwarden.atlassian.net/browse/PM-11129
20-
.ForMember(i => i.LastActivityDate, opt => opt.Ignore())
21-
.ReverseMap();
2212
CreateMap<C.Installation, Installation>().ReverseMap();
2313
}
2414
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Bit.Core.Platform.Installations;
2+
using Bit.Infrastructure.IntegrationTest.Comparers;
3+
using Xunit;
4+
5+
namespace Bit.Infrastructure.IntegrationTest.Platform.Installations;
6+
7+
public class InstallationRepositoryTests
8+
{
9+
[DatabaseTheory, DatabaseData]
10+
public async Task GetByIdAsync_Works(IInstallationRepository installationRepository)
11+
{
12+
var installation = await installationRepository.CreateAsync(new Installation
13+
{
14+
Email = "test@email.com",
15+
Key = "installation_key",
16+
Enabled = true,
17+
});
18+
19+
var retrievedInstallation = await installationRepository.GetByIdAsync(installation.Id);
20+
21+
Assert.NotNull(retrievedInstallation);
22+
Assert.Equal("installation_key", retrievedInstallation.Key);
23+
}
24+
25+
[DatabaseTheory, DatabaseData]
26+
public async Task UpdateAsync_Works(IInstallationRepository installationRepository)
27+
{
28+
var installation = await installationRepository.CreateAsync(new Installation
29+
{
30+
Email = "test@email.com",
31+
Key = "installation_key",
32+
Enabled = true,
33+
});
34+
35+
var now = DateTime.UtcNow;
36+
37+
installation.LastActivityDate = now;
38+
39+
await installationRepository.ReplaceAsync(installation);
40+
41+
var retrievedInstallation = await installationRepository.GetByIdAsync(installation.Id);
42+
43+
Assert.NotNull(retrievedInstallation.LastActivityDate);
44+
Assert.Equal(now, retrievedInstallation.LastActivityDate.Value, LaxDateTimeComparer.Default);
45+
}
46+
}

0 commit comments

Comments
 (0)