public async Task DeleteClientPropertyAsync() { IClientRepository clientRepository = new ClientDapperRepository(_configuration); var localizerMock = new Mock <IClientServiceResources>(); var localizer = localizerMock.Object; IClientService clientService = new ClientService(clientRepository, localizer); //Generate random new client var client = ClientDtoMock.GenerateRandomClient(0); var clientId = await clientService.AddClientAsync(client); //Get new client var clientEntity = await clientRepository.GetClientAsync(clientId); var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); //Generate random new Client Property var clientProperty = ClientDtoMock.GenerateRandomClientProperty(0, clientEntity.Id); //Add new client Property var clientPropertyId = await clientService.AddClientPropertyAsync(clientProperty); //Get inserted client property var property = await clientRepository.GetClientPropertyAsync(clientPropertyId); //Map entity to model var propertiesDto = property.ToModel(); //Get new client Property var clientPropertiesDto = await clientService.GetClientPropertyAsync(property.Id); //Assert clientPropertiesDto.ShouldBeEquivalentTo(propertiesDto, options => options.Excluding(o => o.ClientPropertyId)); //Delete client Property await clientService.DeleteClientPropertyAsync(clientPropertiesDto); //Get removed client Property var deletedClientProperty = await clientRepository.GetClientPropertyAsync(property.Id); //Assert after delete it deletedClientProperty.Should().BeNull(); }
public async Task AddClientPropertyAsync() { IClientRepository clientRepository = new ClientDapperRepository(_configuration); //Generate random new client without id var client = ClientMock.GenerateRandomClient(); //Add new client var clientId = await clientRepository.AddClientAsync(client); //Get new client var clientEntity = await clientRepository.GetClientAsync(clientId); //Assert new client clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id) .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "AllowedGrantTypes\\[.+\\].Id")) .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "RedirectUris\\[.+\\].Id")) .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "PostLogoutRedirectUris\\[.+\\].Id")) .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "AllowedScopes\\[.+\\].Id")) .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "IdentityProviderRestrictions\\[.+\\].Id")) .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "AllowedCorsOrigins\\[.+\\].Id"))); //Generate random new Client property var clientProperty = ClientMock.GenerateRandomClientProperty(); //Add new client property var clientPropertyId = await clientRepository.AddClientPropertyAsync(clientEntity.Id, clientProperty); //Get new client property var newClientProperty = await clientRepository.GetClientPropertyAsync(clientPropertyId); newClientProperty.ShouldBeEquivalentTo(clientProperty, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); }