コード例 #1
0
        public async Task AddAndDeleteNewSolarSystem_Ok()
        {
            //Arrange
            var id     = Guid.NewGuid();
            var system = new SolarSystem
            {
                Id   = id,
                Name = "Test"
            };

            //Act
            await m_repository.CreateAsync(system);

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

            Assert.Equal(id, systems.First().Id);
            Assert.Equal("Test", systems.First().Name);
            await m_repository.DeleteAsync(system);

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

            Assert.Empty(emptyResponse);
        }
コード例 #2
0
        public async Task DeleteSolarSystemAsync(Guid id)
        {
            try
            {
                var solarSystem = await EnsureSolarSystemExistAsync(id);

                await m_repository.DeleteAsync(solarSystem);
            }
            catch (ValidationException e)
            {
                m_logger.LogWarning(e, "A validation failed");
                throw;
            }
            catch (Exception e) when(e.GetType() != typeof(ValidationException))
            {
                m_logger.LogCritical(e, $"Unexpected Exception while trying to delete a solar system for id : {id}");
                throw;
            }
        }