Beispiel #1
0
        public async Task RemoveAsync_ShouldCallSyncMethod_WhenIdIsGiven()
        {
            // Arrange
            const int id = 42;

            _mockInner.Setup(i => i.Remove(id));

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            await subject.RemoveAsync(id).ConfigureAwait(false);

            // Assert
            _mockInner.VerifyAll();
        }
Beispiel #2
0
        public async Task UpdateAsync_ShouldCallSyncMethod()
        {
            // Arrange
            var entity = new FakeEntity <int> {
                Id = 42
            };

            _mockInner.Setup(i => i.Update(entity));

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            await subject.UpdateAsync(entity).ConfigureAwait(false);

            // Assert
            _mockInner.VerifyAll();
        }
Beispiel #3
0
        public async Task GetAllAsync_ShouldCallSyncMethod_AndReturnResult()
        {
            // Arrange
            var data = Enumerable.Empty <FakeEntity <int> >();

            _mockInner
            .Setup(i => i.GetAll())
            .Returns(data);

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            var result = await subject.GetAllAsync().ConfigureAwait(false);

            // Assert
            result.Should().BeSameAs(data);
            _mockInner.VerifyAll();
        }
Beispiel #4
0
        public async Task TryRemoveAsync_ShouldCallSyncMethod_AndReturnResult_WhenIdIsGiven(bool expected)
        {
            // Arrange
            const int id = 42;

            _mockInner
            .Setup(i => i.TryRemove(id))
            .Returns(expected);

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            var success = await subject.TryRemoveAsync(id).ConfigureAwait(false);

            // Assert
            success.Should().Be(expected);
            _mockInner.VerifyAll();
        }
Beispiel #5
0
        public async Task GetCountAsync_ShouldCallSyncMethod_AndReturnResult()
        {
            // Arrange
            const long count = 38;

            _mockInner
            .Setup(i => i.GetCount())
            .Returns(count);

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            var result = await subject.GetCountAsync().ConfigureAwait(false);

            // Assert
            result.Should().Be(count);
            _mockInner.VerifyAll();
        }
Beispiel #6
0
        public async Task TryGetByIdAsync_ShouldCallSyncMethod_AndReturnNull_WhenEntityIsNotFound()
        {
            // Arrange
            const int        id     = 42;
            FakeEntity <int> person = null;

            _mockInner
            .Setup(i => i.TryGetById(id, out person))
            .Returns(false);

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            var result = await subject.TryGetByIdAsync(id).ConfigureAwait(false);

            // Assert
            result.Should().BeNull();
            _mockInner.VerifyAll();
        }
Beispiel #7
0
        public async Task GetByIdAsync_ShouldCallSyncMethod_AndReturnResult()
        {
            // Arrange
            var entity = new FakeEntity <int> {
                Id = 42
            };

            _mockInner
            .Setup(i => i.GetById(entity.Id))
            .Returns(entity);

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            var result = await subject.GetByIdAsync(entity.Id).ConfigureAwait(false);

            // Assert
            result.Should().BeSameAs(entity);
            _mockInner.VerifyAll();
        }
Beispiel #8
0
        public async Task TryUpdateAsync_ShouldCallSyncMethod_AndReturnResult(bool expected)
        {
            // Arrange
            var entity = new FakeEntity <int> {
                Id = 42
            };

            _mockInner
            .Setup(i => i.TryUpdate(entity))
            .Returns(expected);

            var subject = new AsyncRepositoryAdapter <FakeEntity <int>, int>(_mockInner.Object);

            // Act
            var success = await subject.TryUpdateAsync(entity).ConfigureAwait(false);

            // Assert
            success.Should().Be(expected);
            _mockInner.VerifyAll();
        }