예제 #1
0
        public async Task ItemsController_ComputeTotalPrice()
        {
            // Arrange
            double value           = 20;
            var    mockRepo        = new Mock <IItemsBLL>();
            var    httpServiceMock = new Mock <IHttpServices>();

            httpServiceMock.Setup(x => x.GetClaimsIdentity(It.IsAny <HttpContext>()))
            .Returns(new UserClaim());
            mockRepo.Setup(x => x.ComputeTotalPriceAsync(It.IsAny <double>(), It.IsAny <double>(), It.IsAny <int>(), It.IsAny <UserType>(), It.IsAny <string>()))
            .ReturnsAsync(value);
            var controller = new ItemsController(mockRepo.Object, httpServiceMock.Object);

            // Act
            var result = await controller.ComputePrice(10, 2, 1);

            // Assert
            Assert.Equal(value, result);
        }