public void AddSupplier_ThrowException_WhenSupplierIsNull() { //ARRANGE var Assistante = new MSAssistantRole(new Mock <IMSUnitOfWork>().Object); //ACT Assert.ThrowsException <ArgumentNullException>(() => Assistante.AddSupplier(null)); //TODO TEST IF INSERT IS CALLED Times.None: mockSupplierRepository.Verify(x => x.Insert(It.IsAny<SupplierTO>()), Times.Once); }
public void AddSupplier_ThrowIsNullOrWhiteSpaceException_WhenSupplierNameISEmptyString() { //ARRANGE var Assistante = new MSAssistantRole(new Mock <IMSUnitOfWork>().Object); var SupplierToAdd = new SupplierTO { Id = 0, Name = "" }; //ACT Assert.ThrowsException <IsNullOrWhiteSpaceException>(() => Assistante.AddSupplier(SupplierToAdd)); //TODO TEST IF INSERT IS CALLED Times.None: mockSupplierRepository.Verify(x => x.Insert(It.IsAny<SupplierTO>()), Times.Once); }
public void AddSupplier_ThrowException_WhenSupplierIDisDiferentOfZero() { //ARRANGE var Assistante = new MSAssistantRole(new Mock <IMSUnitOfWork>().Object); var SupplierToAdd = new SupplierTO { Id = 10, Name = "ExistantSupplier" }; //ACT Assert.ThrowsException <Exception>(() => Assistante.AddSupplier(SupplierToAdd)); //TODO TEST IF INSERT IS CALLED Times.None: mockSupplierRepository.Verify(x => x.Insert(It.IsAny<SupplierTO>()), Times.Once); }
public void AddSupplier_SupplierRepositoryIsCalledOnce_WhenAValidSupplierIsProvidedAndAddToDB() { //ARRANGE var mockSupplierRepository = new Mock <ISupplierRepository>(); mockSupplierRepository.Setup(x => x.Add(It.IsAny <SupplierTO>())); var mockUoW = new Mock <IMSUnitOfWork>(); mockUoW.Setup(x => x.SupplierRepository).Returns(mockSupplierRepository.Object); var Assistante = new MSAssistantRole(mockUoW.Object); var SupplierToAdd = new SupplierTO { Id = 0, Name = "InexistantSupplier" }; //ACT Assistante.AddSupplier(SupplierToAdd); mockSupplierRepository.Verify(x => x.Add(It.IsAny <SupplierTO>()), Times.Once); }
public void AddSupplier_ReturnsTrue_WhenAValidSupplierIsProvidedAndAddToDB() { //ARRANGE var mockSupplierRepository = new Mock <ISupplierRepository>(); mockSupplierRepository.Setup(x => x.Add(It.IsAny <SupplierTO>())); var mockUoW = new Mock <IMSUnitOfWork>(); mockUoW.Setup(x => x.SupplierRepository).Returns(mockSupplierRepository.Object); var Assistante = new MSAssistantRole(mockUoW.Object); var SupplierToAdd = new SupplierTO { Id = 0, Name = "InexistantSupplier" }; //ACT var ReturnValueToAssert = Assistante.AddSupplier(SupplierToAdd); Assert.IsTrue(ReturnValueToAssert); }