Пример #1
0
        public async Task browse_async_should_invoke_get_all_async()
        {
            var userRepository = new Mock <IUserRepository>();
            var mapper         = new Mock <IMapper>();

            var adService = new AdsService(userRepository.Object, mapper.Object);
            var users     = await adService.BrowseAsync();

            userRepository.Verify(x => x.GetAllAsync(), Times.Once);
        }
Пример #2
0
        public async Task browse_async_with_id_should_invoke_get_async_by_id()
        {
            var guid           = Guid.NewGuid();
            var userRepository = new Mock <IUserRepository>();
            var mapper         = new Mock <IMapper>();

            var adService = new AdsService(userRepository.Object, mapper.Object);
            //user is null
            await Assert.ThrowsAsync <ArgumentNullException>(
                async() => await adService.BrowseAsync(guid)
                );

            userRepository.Verify(x => x.GetAsync(It.Is <Guid>(y => y == guid)), Times.Once);
        }