public void GetSuppliers_ThrowsException_WhenMoreThanONEDefaultSupplierIsSetup()
        {
            //ARRANGE
            var mockSupplierRepository = new Mock <ISupplierRepository>();

            mockSupplierRepository.Setup(x => x.GetAll()).Returns(SupplierListWith2True());
            mockSupplierRepository.Setup(x => x.GetDefaultSupplier()).Returns(SupplierListWith2True().FirstOrDefault(x => x.IsDefault == true));

            var mockUoW = new Mock <IMSUnitOfWork>();

            mockUoW.Setup(x => x.SupplierRepository).Returns(mockSupplierRepository.Object);

            var Assistante = new MSAssistantRole(mockUoW.Object);

            //ACT & ASSERT
            var ExceptionToTest = Assert.ThrowsException <Exception>(() => Assistante.GetDefaultSupplier());

            Assert.AreEqual($"GetDefaultSupplier(). Default Supplier not well configured in DB", ExceptionToTest.Message);
        }
        public void GetDefaultSupplier_SupplierRepositoryIsCalledOnce_WhenCalled()
        {
            //ARRANGE
            var SupplierId             = 2;
            var mockSupplierRepository = new Mock <ISupplierRepository>();

            mockSupplierRepository.Setup(x => x.GetAll()).Returns(SupplierList());
            mockSupplierRepository.Setup(x => x.GetDefaultSupplier()).Returns(new SupplierTO {
                Id = SupplierId, Name = $"Suplier{SupplierId}", IsDefault = true
            });

            var mockUoW = new Mock <IMSUnitOfWork>();

            mockUoW.Setup(x => x.SupplierRepository).Returns(mockSupplierRepository.Object);

            var Assistante = new MSAssistantRole(mockUoW.Object);

            //ACT
            var DefaultSupplier = Assistante.GetDefaultSupplier();

            //ASSERT
            mockSupplierRepository.Verify(x => x.GetDefaultSupplier(), Times.Once);
        }
        public void GetDefaultSupplier_ReturnsSupplierInDB_WhenCalled()
        {
            //ARRANGE
            var SupplierId             = 2;
            var mockSupplierRepository = new Mock <ISupplierRepository>();

            mockSupplierRepository.Setup(x => x.GetAll()).Returns(SupplierList());
            mockSupplierRepository.Setup(x => x.GetDefaultSupplier()).Returns(new SupplierTO {
                Id = SupplierId, Name = $"Suplier{SupplierId}", IsDefault = true
            });

            var mockUoW = new Mock <IMSUnitOfWork>();

            mockUoW.Setup(x => x.SupplierRepository).Returns(mockSupplierRepository.Object);

            var Assistante = new MSAssistantRole(mockUoW.Object);

            //ACT
            var DefaultSupplier = Assistante.GetDefaultSupplier();

            //ASSERT
            Assert.AreEqual(SupplierId, DefaultSupplier.Id);
        }