Example #1
0
        public async Task ShouldDeleteClientProperties()
        {
            await Login();

            var newClient = await AddClient();

            var newProperty = ClientViewModelFaker.GenerateSaveProperty(newClient.ClientId).Generate();

            // Create one
            var httpResponse = await _client.PostAsync($"/clients/{newClient.ClientId}/properties", new StringContent(newProperty.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json));

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };
            httpResponse.Headers.Location.Should().NotBeNull();
            httpResponse.Headers.Location.PathAndQuery.Should().Contain("/properties");

            httpResponse = await _client.GetAsync($"/clients/{newClient.ClientId}/properties");

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };

            // Deserialize and examine results.
            var stringResponse = await httpResponse.Content.ReadAsStringAsync();

            var properties = stringResponse.FromJson <IEnumerable <ClientPropertyViewModel> >();

            httpResponse = await _client.DeleteAsync($"/clients/{newClient.ClientId}/properties/{properties.First().Key}");

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };
        }
Example #2
0
        public async Task Should_Add_New_ClientProperty()
        {
            var command = ClientViewModelFaker.GenerateSaveClient().Generate();

            await _clientAppService.Save(command);

            var property = ClientViewModelFaker.GenerateSaveProperty(command.ClientId).Generate();

            await _clientAppService.SaveProperty(property);

            _database.Clients.Include(s => s.Properties).FirstOrDefault(s => s.ClientId == command.ClientId)?.Properties.Should().HaveCountGreaterOrEqualTo(1);
        }
Example #3
0
        public async Task Should_Not_Add_New_ClientProperty_When_Client_Doesnt_Exist()
        {
            var command  = ClientViewModelFaker.GenerateSaveClient().Generate();
            var property = ClientViewModelFaker.GenerateSaveProperty(command.ClientId).Generate();

            var result = await _clientAppService.SaveProperty(property);

            _notifications.GetNotifications().Select(s => s.Value).ToList().ForEach(_output.WriteLine);

            _database.ClientProperties.Include(i => i.Client).Where(f => f.Client.ClientId == command.ClientId).Should().NotBeNull();

            result.Should().BeFalse(becauseArgs: _notifications.GetNotificationsByKey());
        }
        public async Task ShouldAddNewClientProperty()
        {
            var command = ClientViewModelFaker.GenerateSaveClient().Generate();

            await _clientAppService.Save(command);

            var property = ClientViewModelFaker.GenerateSaveProperty().Generate();

            await _clientAppService.SaveProperty(property);

            _database.Clients.FirstOrDefault(s => s.ClientId == command.ClientId).Should().NotBeNull();
            _database.ClientProperties.Include(i => i.Client).Where(f => f.Client.ClientId == command.ClientId).Should().NotBeNull();
        }
Example #5
0
        public async Task ShouldAddNewClientProperty()
        {
            await Login();

            var newClient = await AddClient();

            var newProperty = ClientViewModelFaker.GenerateSaveProperty(newClient.ClientId).Generate();

            // Create one
            var httpResponse = await _client.PostAsync($"/clients/{newClient.ClientId}/properties", new StringContent(newProperty.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json));

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };
            httpResponse.Headers.Location.Should().NotBeNull();
            httpResponse.Headers.Location.PathAndQuery.Should().Contain("/properties");
        }