public async Task UpdateNewSolarSystem_Ok()
        {
            //Arrange
            var id     = Guid.NewGuid();
            var system = new SolarSystem
            {
                Id   = id,
                Name = "Test"
            };

            //Act
            await m_repository.CreateAsync(system);

            system.Name = "Modified";
            await m_repository.UpdateAsync(system);

            var(_, updatedResponse) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new SolarSystemFilter
            {
                SearchTerm = id.ToString()
            });

            //Assert
            Assert.Equal(id, updatedResponse.First().Id);
            Assert.Equal("Modified", updatedResponse.First().Name);
            await m_repository.DeleteAsync(system);
        }
Пример #2
0
        public async Task UpdateSolarSystemAsync(SolarSystem solarSystem)
        {
            try
            {
                var validationError = solarSystem.Validate();
                if (validationError.Any())
                {
                    throw new ValidationException($"A validation exception was raised while trying to update a solar system : {JsonConvert.SerializeObject(validationError, Formatting.Indented)}");
                }
                await EnsureSolarSystemExistAsync(solarSystem.Id);

                await m_repository.UpdateAsync(solarSystem);
            }
            catch (ValidationException e) when(e.GetType() != typeof(ValidationException))
            {
                m_logger.LogWarning(e, "A validation failed");
                throw;
            }
            catch (Exception e)
            {
                m_logger.LogCritical(e, $"Unexpected Exception while trying to update a solar system with the properties : {JsonConvert.SerializeObject(solarSystem, Formatting.Indented)}");
                throw;
            }
        }