public void StorageReturnNull_ReturnFail()
        {
            var storageMock = new Mock <ProxyFigureStorage>();

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

            var calculator = new ProxyFigureCalculator(storageMock.Object, null);

            Result <double> result = calculator.Calculate(new CircleDescription {
                Radius = 1
            });

            Assert.AreEqual(result.Fail, true);
        }
        public void ValidatorReturnSuccess_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);

            var calculator = new ProxyFigureCalculator(storageMock.Object, validator);

            Result <double> result = calculator.Calculate(new CircleDescription {
                Radius = 1
            });

            Assert.AreEqual(result.Success, true);
        }
Exemplo n.º 3
0
 public CalcAreaHandler(IQueryFactory queryFactory, ProxyFigureCalculator figureCalculator, ProxyFigureDescriptionProvider descriptionProvider)
 {
     _queryFactory        = queryFactory;
     _figureCalculator    = figureCalculator;
     _descriptionProvider = descriptionProvider;
 }
Exemplo n.º 4
0
 public CalcAreaHandlerTests()
 {
     _validator           = new ProxyFigureValidator(_storage);
     _calculator          = new ProxyFigureCalculator(_storage, _validator);
     _descriptionProvider = new ProxyFigureDescriptionProvider(_storage);
 }