public async Task HandleShouldReturnFailWhenDatabaseSpecificErrorOccurs()
        {
            // Arrange
            var id = Guid.NewGuid();

            var iconReadRepositoryMock = new Mock <IIconReadRepository>();

            iconReadRepositoryMock.Setup(x => x.GetAsync(id)).Throws <SomeDatabaseSpecificException>();
            var iconReadRepository = iconReadRepositoryMock.Object;

            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(x => x.Map <IconModel>(It.IsAny <object>())).Returns(new IconModel());
            var mapper = mapperMock.Object;

            var query = new GetIconQuery(id);

            var handler = new GetIconQueryHandler(mapper, iconReadRepository);

            // Act
            var result = await handler.Handle(query, CancellationToken.None);

            // Assert
            result.IsFailure.Should().BeTrue();
            result.Failures.Should().OnlyContain(x => x.Message == CustomFailures.GetIconFailure);
        }
        public async Task HandleShouldReturnOk()
        {
            // Arrange
            var    id       = Guid.NewGuid();
            string name     = "name";
            string dataPath = "datapath";

            var iconReadRepositoryMock = new Mock <IIconReadRepository>();

            iconReadRepositoryMock.Setup(x => x.GetAsync(id)).Returns(Task.FromResult(new Icon(id, name, dataPath)));
            var iconReadRepository = iconReadRepositoryMock.Object;

            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(x => x.Map <IconModel>(It.IsAny <object>())).Returns(new IconModel());
            var mapper = mapperMock.Object;

            var query = new GetIconQuery(id);

            var handler = new GetIconQueryHandler(mapper, iconReadRepository);

            // Act
            var result = await handler.Handle(query, CancellationToken.None);

            // Assert
            result.IsFailure.Should().BeFalse();
            result.Should().BeOfType(typeof(Result <IconModel>));
        }
        public async Task HandleShouldReturnFailWhenNotFound()
        {
            // Arrange
            var id = Guid.NewGuid();

            var iconReadRepositoryMock = new Mock <IIconReadRepository>();

            iconReadRepositoryMock.Setup(x => x.GetAsync(id)).Throws <EntityNotFoundDbException>();
            var iconReadRepository = iconReadRepositoryMock.Object;

            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(x => x.Map <IconModel>(It.IsAny <object>())).Returns(new IconModel());
            var mapper = mapperMock.Object;

            var query = new GetIconQuery(id);

            var handler = new GetIconQueryHandler(mapper, iconReadRepository);

            // Act
            var result = await handler.Handle(query, CancellationToken.None);

            // Assert
            result.IsFailure.Should().BeTrue();
            result.Failures.Should().OnlyContain(x => x.Code == HandlerFaultCode.NotFound.Name);
        }