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())));
        }
Exemplo n.º 2
0
        public async Task UpdateAsync_NoId_Fails(OrganizationConnectionData <BillingSyncConfig> data,
                                                 SutProvider <UpdateOrganizationConnectionCommand> sutProvider)
        {
            data.Id = null;

            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);
        public async Task <OrganizationConnection> UpdateAsync <T>(OrganizationConnectionData <T> connectionData) where T : new()
        {
            if (!connectionData.Id.HasValue)
            {
                throw new Exception("Cannot update connection, Connection does not exist.");
            }

            var connection = await _organizationConnectionRepository.GetByIdAsync(connectionData.Id.Value);

            if (connection == null)
            {
                throw new NotFoundException();
            }

            var entity = connectionData.ToEntity();
            await _organizationConnectionRepository.UpsertAsync(entity);

            return(entity);
        }
 public async Task <OrganizationConnection> CreateAsync <T>(OrganizationConnectionData <T> connectionData) where T : new()
 {
     return(await _organizationConnectionRepository.CreateAsync(connectionData.ToEntity()));
 }