mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Turn on file scoped namespaces (#2225)
This commit is contained in:
@ -8,20 +8,19 @@ using Bit.Test.Common.Helpers;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationConnections
|
||||
{
|
||||
[SutProviderCustomize]
|
||||
public class CreateOrganizationConnectionCommandTests
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task CreateAsync_CallsCreate(OrganizationConnectionData<BillingSyncConfig> data,
|
||||
SutProvider<CreateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
await sutProvider.Sut.CreateAsync(data);
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationConnections;
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().Received(1)
|
||||
.CreateAsync(Arg.Is(AssertHelper.AssertPropertyEqual(data.ToEntity())));
|
||||
}
|
||||
[SutProviderCustomize]
|
||||
public class CreateOrganizationConnectionCommandTests
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task CreateAsync_CallsCreate(OrganizationConnectionData<BillingSyncConfig> data,
|
||||
SutProvider<CreateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
await sutProvider.Sut.CreateAsync(data);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().Received(1)
|
||||
.CreateAsync(Arg.Is(AssertHelper.AssertPropertyEqual(data.ToEntity())));
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,19 @@ using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationConnections
|
||||
{
|
||||
[SutProviderCustomize]
|
||||
public class DeleteOrganizationConnectionCommandTests
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task DeleteAsync_CallsDelete(OrganizationConnection connection,
|
||||
SutProvider<DeleteOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
await sutProvider.Sut.DeleteAsync(connection);
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationConnections;
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().Received(1)
|
||||
.DeleteAsync(connection);
|
||||
}
|
||||
[SutProviderCustomize]
|
||||
public class DeleteOrganizationConnectionCommandTests
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task DeleteAsync_CallsDelete(OrganizationConnection connection,
|
||||
SutProvider<DeleteOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
await sutProvider.Sut.DeleteAsync(connection);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().Received(1)
|
||||
.DeleteAsync(connection);
|
||||
}
|
||||
}
|
||||
|
@ -10,50 +10,49 @@ using Bit.Test.Common.Helpers;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationConnections
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationConnections;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class UpdateOrganizationConnectionCommandTests
|
||||
{
|
||||
[SutProviderCustomize]
|
||||
public class UpdateOrganizationConnectionCommandTests
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateAsync_NoId_Fails(OrganizationConnectionData<BillingSyncConfig> data,
|
||||
SutProvider<UpdateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateAsync_NoId_Fails(OrganizationConnectionData<BillingSyncConfig> data,
|
||||
SutProvider<UpdateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
data.Id = null;
|
||||
data.Id = null;
|
||||
|
||||
var exception = await Assert.ThrowsAsync<Exception>(() => sutProvider.Sut.UpdateAsync(data));
|
||||
var exception = await Assert.ThrowsAsync<Exception>(() => sutProvider.Sut.UpdateAsync(data));
|
||||
|
||||
Assert.Contains("Cannot update connection, Connection does not exist.", exception.Message);
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().DidNotReceiveWithAnyArgs()
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
Assert.Contains("Cannot update connection, Connection does not exist.", exception.Message);
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().DidNotReceiveWithAnyArgs()
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateAsync_ConnectionDoesNotExist_ThrowsNotFound(
|
||||
OrganizationConnectionData<BillingSyncConfig> data,
|
||||
SutProvider<UpdateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(data));
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateAsync_ConnectionDoesNotExist_ThrowsNotFound(
|
||||
OrganizationConnectionData<BillingSyncConfig> data,
|
||||
SutProvider<UpdateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(data));
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().DidNotReceiveWithAnyArgs()
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().DidNotReceiveWithAnyArgs()
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateAsync_CallsUpsert(OrganizationConnectionData<BillingSyncConfig> data,
|
||||
OrganizationConnection existing,
|
||||
SutProvider<UpdateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
data.Id = existing.Id;
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateAsync_CallsUpsert(OrganizationConnectionData<BillingSyncConfig> data,
|
||||
OrganizationConnection existing,
|
||||
SutProvider<UpdateOrganizationConnectionCommand> sutProvider)
|
||||
{
|
||||
data.Id = existing.Id;
|
||||
|
||||
sutProvider.GetDependency<IOrganizationConnectionRepository>().GetByIdAsync(data.Id.Value).Returns(existing);
|
||||
await sutProvider.Sut.UpdateAsync(data);
|
||||
sutProvider.GetDependency<IOrganizationConnectionRepository>().GetByIdAsync(data.Id.Value).Returns(existing);
|
||||
await sutProvider.Sut.UpdateAsync(data);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().Received(1)
|
||||
.UpsertAsync(Arg.Is(AssertHelper.AssertPropertyEqual(data.ToEntity())));
|
||||
}
|
||||
await sutProvider.GetDependency<IOrganizationConnectionRepository>().Received(1)
|
||||
.UpsertAsync(Arg.Is(AssertHelper.AssertPropertyEqual(data.ToEntity())));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user