示例#1
0
        public async void DeleteService_ShouldRemoveAll_IfReportsOlderThan3Hours()
        {
            // Given
            _db.Initialise();

            _db.Add(
                new Report
            {
                Latitude         = 54.597216,
                Longitude        = -5.930420,
                CreatedAt        = (DateTime.Now).AddHours(-3),
                AdditionalInfo   = "Report from Belfast City Hall",
                Active           = true,
                ThreeWordAddress = "twigs.purple.pulled",
                City             = _city.GetOutsideCity()
            }
                );
            _db.Add(
                new Report
            {
                Latitude         = 54.597216,
                Longitude        = -5.930420,
                CreatedAt        = (DateTime.Now).AddHours(-4),
                AdditionalInfo   = "Report from Belfast City Hall",
                Active           = true,
                ThreeWordAddress = "twigs.purple.pulled",
                City             = _city.GetOutsideCity()
            }
                );
            _db.Add(
                new Report
            {
                Latitude         = 54.597216,
                Longitude        = -5.930420,
                CreatedAt        = (DateTime.Now).AddHours(-6),
                AdditionalInfo   = "Report from Belfast City Hall",
                Active           = true,
                ThreeWordAddress = "twigs.purple.pulled",
                City             = _city.GetOutsideCity()
            }
                );
            _db.SaveChanges();

            // When
            await _svc.CleanRecordsASync();

            // Then
            Assert.Empty(_db.Reports.ToList());
        }