示例#1
0
        public async Task Get_ProductsWithoutResult_Ok()
        {
            var productsDto = UtilityTest.GenerateProductDtoInDifferenttegoryAsync();

            var _mediatorMock = new Mock <IMediatorService>();

            _mediatorMock.Setup(x => x.Send(It.IsAny <GetAllProductQuery>(),
                                            It.IsAny <CancellationToken>()))
            .ReturnsAsync(productsDto);

            var _loggerMock = new Mock <ILogger <ProductsController> >();

            var _mockMapper = new Mock <IMapper>();



            var productsController = new ProductsController(_loggerMock.Object, _mediatorMock.Object, _mockMapper.Object);
            var actionResult       = await productsController.GetProducts();



            var viewResult = Assert.IsType <Microsoft.AspNetCore.Mvc.OkObjectResult>(actionResult);

            Assert.IsAssignableFrom <List <ProductDto> >(viewResult.Value);
        }
示例#2
0
        public void GetAllCoefficientPonderationTest()
        {
            ICalibrageApp serviceCalibrageApp = UtilityTest.CreateInstanceService <ICalibrageApp>();
            var           result = serviceCalibrageApp.GetAllCoeffcientPonderations();

            Assert.IsTrue(result != null);
            Assert.AreEqual(result.Count(), 40);
        }
示例#3
0
        public void GetNoteMaxPge_DesordreStructureMaconnerieBetonTest()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();
            //Act
            var resultOfService = hidalgoService.GetNotesMaxForAllDocumentPge_DesordreStructureMaconnerieBeton(EFamilleDesordre.Desordre_structure_Maçonnerie_Beton, ENatureCalibrage.Maçonnerie);

            //Assert
            Assert.AreEqual(resultOfService.Count(), 223);
        }
示例#4
0
        /// <summary>
        /// Méthode de test
        /// </summary>
        public void GetAllDocumentPgeForNatureTravauxEnduitTest()
        {
            //Arrang
            var calculService = UtilityTest.CreateInstanceService <ICalculServiceApp>();

            var listeDocumentPge = calculService.GetAllDocumentPge(Data.Contract.Enum.ENatureCalibrage.Enduit);

            Assert.IsTrue(listeDocumentPge != null);
            Assert.AreEqual(listeDocumentPge.Count(), 109);
        }
示例#5
0
        public void GetNoteMaxPge_FissurationEnduitTest()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();

            //Act
            var resultOfService = hidalgoService.GetNotesMaxForAllDocumentPge_Fissuration(EFamilleDesordre.Fissurations, ENatureCalibrage.Enduit);

            //Assert
            Assert.AreEqual(resultOfService.Count(), 109);
        }
示例#6
0
        public void GetAllLignesAsync()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();

            //Act
            var resultOfService = hidalgoService.GetAllLignesAsync();

            //Assert
            Assert.AreEqual(resultOfService.Result.Count(), 62);
        }
示例#7
0
        public void GetNoteMaxAllDocumentPge()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();

            //Act
            //var resultOfService = hidalgoService.GetAllDocumentPge();

            //Assert
            //Assert.AreEqual(resultOfService.Count(), 404);
        }
 public void Setup()
 {
     _settings           = UtilityTest.GetMongoDbSettings();
     _context            = new OrderAppContext(_settings);
     _unitOfWork         = new UnitOfWork(_context);
     _groupRepository    = new GroupRepository(_context);
     _customerRepository = new CustomerRepository(_context);
     _productRepository  = new ProductRepository(_context);
     _paymentRepository  = new PaymentRepository(_context);
     _orderRepository    = new OrderRepository(_context, _unitOfWork);
 }
示例#9
0
        public void GetAllDocumentPgeEnduitTest()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();

            //Act
            var resultOfService = hidalgoService.GetAllDocumentPgeByNatureTravaux(ENatureCalibrage.Enduit);

            //Assert
            Assert.IsTrue(resultOfService != null);
            Assert.AreEqual(resultOfService.Count(), 37);
        }
示例#10
0
        public void GetAllTypeOuvrageTest()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();

            //Act
            var resultOfService = hidalgoService.GetAllTypeOuvrages();

            //Assert
            Assert.IsTrue(resultOfService != null);
            Assert.AreEqual(resultOfService.Count(), 68);
        }
示例#11
0
        public void GetNoteMaxForAllDocumentPge_TravauxConnexesTest()
        {
            //Arrang
            var hidalgoService   = UtilityTest.CreateInstanceService <IHidalgoApp>();
            var listeDocumentPge = hidalgoService.GetAllDocumentPgeByNatureTravaux(Data.Contract.Enum.ENatureCalibrage.Maçonnerie);

            //Act
            hidalgoService.CalculNotesParametresCritere4(this.GetOneProgrammationToTest(), listeDocumentPge);

            //Assert
            Assert.IsTrue(true);
        }
示例#12
0
        public void EtapeCalcul2Test()
        {
            //Arrang
            var hidalgoService = UtilityTest.CreateInstanceService <IHidalgoApp>();

            //Act
            var result = hidalgoService.CalculEtape2(this.GetOneProgrammationToTest());

            //Assert
            //TODO YAR: faut s'assurer que le fichier est générer, a cause de pression du temps, j'ai laissé ce traitement après
            Assert.IsTrue(result != null);
        }
示例#13
0
        public void CalculPessimisteOptimisteTest()
        {
            //Arrang
            var hidalgoService   = UtilityTest.CreateInstanceService <IHidalgoApp>();
            var listeDocumentPge = hidalgoService.GetAllDocumentPgeByNatureTravaux(Data.Contract.Enum.ENatureCalibrage.Maçonnerie);

            //Act
            hidalgoService.CalculPessimisteOptimiste(this.GetOneProgrammationToTest(), listeDocumentPge);

            //Assert: un fichier est généré
            Assert.IsTrue(true);
        }
示例#14
0
        public void CalculCritereC2Test()
        {
            //Arrang
            var hidalgoService   = UtilityTest.CreateInstanceService <IHidalgoApp>();
            var listeDocumentPge = hidalgoService.GetAllDocumentPgeByNatureTravaux(Data.Contract.Enum.ENatureCalibrage.Maçonnerie);

            //Act
            var resultOfService = hidalgoService.CalculCritereC2(this.GetOneProgrammationToTest(), listeDocumentPge);

            //Assert
            Assert.IsTrue(resultOfService != null);
        }
示例#15
0
        public void GetNoteMaxForAllDocumentPge_IgameRatpTest()
        {
            //Arrang
            var hidalgoService   = UtilityTest.CreateInstanceService <IHidalgoApp>();
            var listeDocumentPge = hidalgoService.GetAllDocumentPgeByNatureTravaux(Data.Contract.Enum.ENatureCalibrage.Maçonnerie);

            //Act
            var resultOfService = hidalgoService.GetNoteMaxForAllDocumentPge_ImageRatp(ENatureCalibrage.Maçonnerie, listeDocumentPge);

            //Assert
            Assert.IsTrue(resultOfService != null);
        }
示例#16
0
        public async Task Get_ProductSingleWithoutResult_NotFound()
        {
            var productDto = UtilityTest.GenerateProductDtoInDifferenttegoryAsync().First();

            var modelView = new ProductModelView
            {
                ProductId    = productDto.ProductId,
                CategoryId   = productDto.CategoryId,
                Name         = productDto.Name,
                CategoryName = "CategoryName",
                Description  = "Desc",
                Note         = "Note",
                Options      = new Dictionary <int, string> {
                    { 1, "Bianco" }
                }
            };

            var _mediatorMock = new Mock <IMediatorService>();

            _mediatorMock.Setup(x => x.Send(It.IsAny <GetProductByIdQuery>(),
                                            It.IsAny <CancellationToken>()))
            .ReturnsAsync((ProductModelView)null);

            var _loggerMock = new Mock <ILogger <ProductsController> >();

            var _mockMapper = new Mock <IMapper>();



            var productsController = new ProductsController(_loggerMock.Object, _mediatorMock.Object, _mockMapper.Object);
            var actionResult       = await productsController.GetProduct(100);



            var viewResult = Assert.IsType <Microsoft.AspNetCore.Mvc.NotFoundObjectResult>(actionResult);

            Assert.IsAssignableFrom <string>(viewResult.Value);
            Assert.Equal("Product id 100 not found", viewResult.Value);
        }
示例#17
0
文件: Order.cs 项目: FedeC87p/PhotoSi
        public async Task Create_WithInvalidRules_NullObject()
        {
            var productsMok = (IReadOnlyList <DomainModel.Entities.Products.Product>)(await UtilityTest.GenerateProductInDifferenttegoryAsync());

            var productRepositoryMock = new Mock <IRepository <DomainModel.Entities.Products.Product> >();

            productRepositoryMock
            .Setup(x => x.FindAsync(It.IsAny <IQuerySpecification <DomainModel.Entities.Products.Product> >()))
            .ReturnsAsync(productsMok);


            var rules = new List <IRuleSpecification <OrderDto> >();

            rules.Add(new OrderAcceptOnlyForProductInSameCategorySpecification(productRepositoryMock.Object));

            var orderDto = new OrderDto
            {
                Code         = "12345",
                ProductItems = new List <OrderItemDto>
                {
                    new OrderItemDto {
                        Name        = "Pantanoni Lana",
                        ProductId   = 1,
                        OptionItems = new List <OrderItemOptionDto> {
                            new OrderItemOptionDto {
                                OptionId = 1, Name = "Colore", Value = "Blu"
                            }
                        }
                    },
                    new OrderItemDto {
                        Name        = "Camicia estiva",
                        ProductId   = 3,
                        OptionItems = new List <OrderItemOptionDto> {
                            new OrderItemOptionDto {
                                OptionId = 1, Name = "Colore", Value = "Celeste"
                            },
                            new OrderItemOptionDto {
                                OptionId = 2, Name = "Taglia", Value = "XL"
                            }
                        }
                    }
                }
            };

            var orderValidator = await DomainModel.Entities.Orders.Order.CreateOrderAsync(orderDto, rules, null, null);

            Assert.False(orderValidator.IsValid);
            Assert.Null(orderValidator.ValidatedObject);
        }