예제 #1
0
        public async Task FigureNotFoundInDb_Fail()
        {
            var queryFactoryMock = new Mock <IQueryFactory>();

            queryFactoryMock
            .Setup(x => x.RetrieveFigure(It.IsAny <long>()))
            .Returns(Task.FromResult((Figure)null));

            var handler = new CalcAreaHandler(queryFactoryMock.Object, _calculator, _descriptionProvider);

            Result <CalcAreaResponseData> result =
                await handler.Handle(new CalcAreaRequest(), CancellationToken.None);

            Assert.True(result.Fail);
        }
예제 #2
0
        public async Task RightDescription_Success()
        {
            var queryFactoryMock = new Mock <IQueryFactory>();

            queryFactoryMock
            .Setup(x => x.RetrieveFigure(It.IsAny <long>()))
            .Returns(Task.FromResult(new Figure {
                Type = "circle", Description = "{radius: 1}"
            }));

            var handler = new CalcAreaHandler(queryFactoryMock.Object, _calculator, _descriptionProvider);

            Result <CalcAreaResponseData> result =
                await handler.Handle(new CalcAreaRequest(), CancellationToken.None);

            Assert.True(result.Success);
        }