Exemplo n.º 1
0
        public async void GetOneNotExistingRole()
        {
            //Arrange
            var mockMapper         = new Mock <IMapper>();
            var mockRoleRepository = new Mock <IRoleRepository>();

            mockRoleRepository.Setup(m => m.GetOne(It.IsAny <string>())).ReturnsAsync((Role)null);
            mockMapper.Setup(m => m.Map <Role, RoleOutput>(It.IsAny <Role>())).Returns(new RoleOutput());

            var useCase = new GetOneRoleUseCase(mockRoleRepository.Object, mockMapper.Object);
            //Act
            //Assert
            await Assert.ThrowsAsync <EntityNotFoundException>(() => useCase.Execute("id"));
        }
Exemplo n.º 2
0
        public async void GetOneExistingRole()
        {
            //Arrange
            var mockMapper         = new Mock <IMapper>();
            var mockRoleRepository = new Mock <IRoleRepository>();

            mockRoleRepository.Setup(m => m.GetOne(It.IsAny <string>())).ReturnsAsync(Mock.Of <Role>);
            mockMapper.Setup(m => m.Map <Role, RoleOutput>(It.IsAny <Role>())).Returns(new RoleOutput());

            var useCase = new GetOneRoleUseCase(mockRoleRepository.Object, mockMapper.Object);
            //Act
            var res = await useCase.Execute("id");

            //Assert
            Assert.IsType <RoleOutput>(res);
        }