Esempio n. 1
0
        public async void Create_ShouldCreateAndReturnHeroCreated()
        {
            var expected = new Hero();

            _heroRepositoryMock.Setup(t => t.InsertAsync(expected))
            .ReturnsAsync(expected)
            .Verifiable();

            _superPowerServiceMock.Setup(t => t.IsIdExistsAsync(It.IsAny <int>()))
            .ReturnsAsync(true)
            .Verifiable();

            var result = await _serviceTest.InsertAsync(expected);

            Assert.Same(expected, result);
            _heroRepositoryMock.Verify(t => t.InsertAsync(expected), Times.Once);
            _superPowerServiceMock.Verify(t => t.IsIdExistsAsync(It.IsAny <int>()), Times.Once);
            _heroRepositoryMock.Verify(t => t.SaveChangesAsync(), Times.Once);
        }