public async Task <Result <AddFigureResponseData> > Handle(AddFigureRequest request, CancellationToken cancellationToken)
        {
            if (String.IsNullOrWhiteSpace(request.FigureType) || request.FigureDescription == null)
            {
                return(Result <AddFigureResponseData> .MakeFailMessage("error figure"));
            }

            IFigureDescription description = request.FigureDescription;

            Result <Empty> result = _validator.Validate(description);

            if (result.Fail)
            {
                return(Result <AddFigureResponseData> .MakeFail(result.Errors));
            }

            long figureId = await _queryFactory.SaveFigure(new Figure
            {
                Description = JsonConvert.SerializeObject(request.FigureDescription),
                Type        = request.FigureType
            });

            var responseData = new AddFigureResponseData {
                FigureId = figureId
            };

            return(Result <AddFigureResponseData> .MakeSucces(responseData));
        }
        public void StorageReturnNull_ReturnFail()
        {
            var storageMock = new Mock <ProxyFigureStorage>();

            storageMock
            .Setup(x => x.GetProxyFigureProcessor(It.IsAny <IFigureDescription>()))
            .Returns((ProxyFigureProcessors)null);

            var validator = new ProxyFigureValidator(storageMock.Object);

            Result <Empty> result = validator.Validate(new CircleDescription {
                Radius = 1
            });

            Assert.AreEqual(result.Fail, true);
        }
        public void ValidDescription_ReturnSuccess()
        {
            var processor = new ProxyFigureProcessors();

            processor.Init(new CircleValidator(), new CircleCalculator());

            var storageMock = new Mock <ProxyFigureStorage>();

            storageMock
            .Setup(x => x.GetProxyFigureProcessor(It.IsAny <IFigureDescription>()))
            .Returns(processor);

            var validator = new ProxyFigureValidator(storageMock.Object);

            Result <Empty> result = validator.Validate(new CircleDescription {
                Radius = 1
            });

            Assert.AreEqual(result.Success, true);
        }