Пример #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);
        }
Пример #8
0
 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
        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);
        }