Beispiel #1
0
        public async Task DeletingEntitiesByKey_RemoveEntriesWithExisitngKeys()
        {
            // Arrange
            await _db.Database.EnsureDeletedAsync();

            await _db.Database.EnsureCreatedAsync();

            var targetIds = new[]
            {
                Guid.Parse("EFED4F70-8B1A-4BB3-B14B-B6EA2EEE2267"),
                Guid.Parse("323A3F72-3DAB-422B-A306-8E155CE1F61A"),
                Guid.Parse("8299D594-0AA4-4D33-8EB2-4557A2221AF8")
            };

            var preMoamraths = _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArray();

            Assert.Equal(3, preMoamraths.Length);

            sut = new MoamrathRepository(_db);

            // Act
            await sut.DeleteAsync(targetIds);

            // Assert
            var postMoamraths = _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArray();

            Assert.Empty(postMoamraths);
        }
Beispiel #2
0
        public void WhenConstructingTheRepository_ItWill_BeCreated()
        {
            sut = new MoamrathRepository(_db);

            Assert.NotNull(sut);
            Assert.IsAssignableFrom <IKeyedRepository <Moamrath, Guid> >(sut);
        }
Beispiel #3
0
        public async Task GetAsync_WillReturnNull_WhenNotExists(int iteration)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            Moamrath result = await sut.GetAsync(Guid.NewGuid());

            // Assert
            Assert.Null(result);
        }
Beispiel #4
0
        public async Task CheckingExistenceOfMultiples_WillReturnFalse_WhenAnyNotExist(params Guid[] ids)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            bool result = await sut.Exists(ids);

            // Assert
            Assert.False(result);
        }
Beispiel #5
0
        public async Task CheckingExistence_WillReturnFalse_WhenNotExists(int iteration)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            bool result = await sut.Exists(Guid.NewGuid());

            // Assert
            Assert.False(result);
        }
Beispiel #6
0
        public async Task CheckingExistence_WillReturnTrue_WhenExists(string id)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            bool result = await sut.Exists(Guid.Parse(id));

            // Assert
            Assert.True(result);
        }
Beispiel #7
0
        public async Task GetAsyncMultiple_WillReturnAllMatchingEntities(params Guid[] ids)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            IEnumerable <Moamrath> result = await sut.GetAsync(ids);

            // Assert
            Assert.NotEmpty(result);
            Assert.Equal(ids.Length, result.Count());
        }
Beispiel #8
0
        public async Task GetAsyncMultiple_WillReturnOnlyThoseWithMatchingKeys(string id1, string id2)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            IEnumerable <Moamrath> result = await sut.GetAsync(Guid.Parse(id1), Guid.Parse(id2), Guid.NewGuid());

            // Assert
            Assert.NotEmpty(result);
            Assert.Equal(2, result.Count());
        }
Beispiel #9
0
        public async Task GetAsync_WillReturnTheCorrectValue_WhenExists(string id)
        {
            // Arrange
            sut = new MoamrathRepository(_db);

            // Act
            Moamrath result = await sut.GetAsync(Guid.Parse(id));

            // Assert
            Assert.NotNull(result);
            Assert.Equal(Guid.Parse(id), result.Id);
        }
Beispiel #10
0
        public async Task AttemptingADelete_WithEmptyIds_HasNoEffect()
        {
            // Arrange
            sut = new MoamrathRepository(_db);
            var preMoamraths = await _db.Moamraths.CountAsync();

            // Act
            await sut.DeleteAsync();

            // Assert
            var postMoamraths = await _db.Moamraths.CountAsync();

            Assert.Equal(preMoamraths, postMoamraths);
        }
Beispiel #11
0
        public async Task CheckingExistenceOfMultiples_WillReturnTrue_WhenAllExist(params Guid[] ids)
        {
            // Arrange
            await _db.Database.EnsureDeletedAsync();

            await _db.Database.EnsureCreatedAsync();

            sut = new MoamrathRepository(_db);

            // Act
            bool result = await sut.Exists(ids);

            // Assert
            Assert.True(result);
        }
Beispiel #12
0
        public async Task DeletingEntitiesByKey_WillNotAffectNonExistentKeys()
        {
            // Arrange
            await _db.Database.EnsureDeletedAsync();

            await _db.Database.EnsureCreatedAsync();

            var targetIds    = new[] { Guid.Parse("EFED4F70-8B1A-4BB3-B14B-B6EA2EEE2267"), Guid.NewGuid(), Guid.NewGuid() };
            var preMoamraths = await _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArrayAsync();

            Assert.Single(preMoamraths);

            sut = new MoamrathRepository(_db);

            // Act
            await sut.DeleteAsync(targetIds);

            // Assert
            var postMoamraths = await _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArrayAsync();

            Assert.Empty(postMoamraths);
        }