Exemplo n.º 1
0
        public async void CreateAsync_WhenUserRepositoryThrowsException_Tech3_ShoulBubbleUpException()
        {
            // arrange
            var user = new UserProcessing.Core.Models.User {
                FirstName = "test", LastName = "last", EmailAddress = "*****@*****.**", IsActive = true
            };

            _userRepository
            .Setup(i => i.GetUserByEmailAddressAsync(user.EmailAddress))
            .ThrowsAsync(new Exception());

            Exception ex = null;

            try
            {
                var result = await _userCreationDiService.CreateAsync(user);
            }
            catch (Exception e)
            {
                ex = e;
            }

            //assert
            Assert.NotNull(ex);
        }
Exemplo n.º 2
0
        public async void CreateAsync_WhenUserRepositoryThrowsException_ShoulBubbleUpException()
        {
            // arrange
            var user = new UserProcessing.Core.Models.User {
                FirstName = "test", LastName = "last", EmailAddress = "*****@*****.**", IsActive = true
            };

            _userRepository
            .Setup(i => i.GetUserByEmailAddressAsync(user.EmailAddress))
            .ThrowsAsync(new Exception());

            //assert
            await Assert.ThrowsAsync <Exception>(() => _userCreationDiService.CreateAsync(user));
        }