// method to test, need remove when done this project private void MenuEditSupplier_Click(object sender, RoutedEventArgs e) { //If found a ListSuplier, selected for Tabcontrol var index = TabControlManagement.GetIndexByTitle(MainTabControl, UsecaseStringContants.editSupplier); if (index >= 0) { MainTabControl.SelectedIndex = index; } //If not found tab was ListSuplier, add and selected else { SupplierBusiness supplierBusiness = new SupplierBusiness(); var supplier = supplierBusiness.GetAll()[0]; SupplierViewModel supplierViewModel = new SupplierViewModel() { SupplierId = supplier.SupplierId, SupplierName = supplier.SupplierName, Description = supplier.Description }; EditSupplierUserControl editSupplierUserControl = new EditSupplierUserControl(supplierViewModel); CustomTabItem customTabItem = new CustomTabItem() { Title = UsecaseStringContants.editSupplier, Content = editSupplierUserControl }; MainTabControl.Items.Add(customTabItem); MainTabControl.SelectedItem = customTabItem; } CurrenTabTitle.Content = UsecaseStringContants.editSupplier; this.Title = UsecaseStringContants.editSupplier; }
public void GetAll_ReturnsAnEmptyList_WhenThereAreNoSuppliers() { // Arrange var suppliers = new List <Supplier>().AsQueryable(); var supplierMockDbSet = new Mock <DbSet <Supplier> >(); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Suppliers).Returns(supplierMockDbSet.Object); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act var allSuppliers = supplierBusiness.GetAll(); // Assert int expectedCount = 0; Assert.AreEqual(expectedCount, allSuppliers.Count, "List of all suppliers is not empty"); }
public void Update_SuccessfullyUpdatesSupplier_WhenDataIsCorrect() { // Arrange var countries = new List <Country> { new Country { Name = "TestCountry1", Id = 1 } }.AsQueryable(); var cities = new List <City> { new City { Name = "TestCity1", Id = 1, CountryId = 1 } }.AsQueryable(); var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1, CityId = 1 } }.AsQueryable(); var mockDbCountrySet = new Mock <DbSet <Country> >(); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator()); var mockDbCitySet = new Mock <DbSet <City> >(); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.Provider).Returns(cities.Provider); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.Expression).Returns(cities.Expression); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.ElementType).Returns(cities.ElementType); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.GetEnumerator()).Returns(cities.GetEnumerator()); var suppliermockDbSet = new Mock <DbSet <Supplier> >(); suppliermockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); suppliermockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); suppliermockDbSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); suppliermockDbSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Suppliers).Returns(suppliermockDbSet.Object); mockContext.Setup(c => c.Cities).Returns(mockDbCitySet.Object); mockContext.Setup(c => c.Countries).Returns(mockDbCountrySet.Object); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act supplierBusiness.Update("TestSupplier2", 1, "TestCountry1", "TestCity1"); // Assert mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
public void Delete_ThrowsArgumentException_WhenProductsAreRelatedToTheSupplier() { // Arrange var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1, CityId = 1 }, new Supplier { Name = "TestSupplier2", Id = 2 } }.AsQueryable(); var products = new List <Product> { new Product { Name = "TestProduct1", SupplierId = 1 } }.AsQueryable(); var mockDbSupplierSet = new Mock <DbSet <Supplier> >(); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockDbProductSet = new Mock <DbSet <Product> >(); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.Provider).Returns(products.Provider); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.Expression).Returns(products.Expression); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.ElementType).Returns(products.ElementType); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.GetEnumerator()).Returns(products.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Suppliers).Returns(mockDbSupplierSet.Object); mockContext.Setup(c => c.Products).Returns(mockDbProductSet.Object); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act & Assert try { int idToDelete = 1; supplierBusiness.Delete(idToDelete); Assert.Fail("No exception was thrown."); } catch (ArgumentException ex) { string expectedMessage = string.Format("One or more products are related to this supplier."); Assert.AreEqual(expectedMessage, ex.Message, "Wrong exception was thrown."); } }
// The following methods are responsible for updating information when it is changed. /// <summary> /// Updates the user control every time it is loaded. /// </summary> public void UpdateUserControl() { var eazyCartContext = new EazyCartContext(); this.productBusiness = new ProductBusiness(eazyCartContext); this.categoryBusiness = new CategoryBusiness(eazyCartContext); this.supplierBusiness = new SupplierBusiness(eazyCartContext); this.unitBusiness = new UnitBusiness(eazyCartContext); this.countryBusiness = new CountryBusiness(eazyCartContext); this.cityBusiness = new CityBusiness(eazyCartContext); this.ClearAndUpdateProductTab(); this.ClearAndUpdateDeliveryTab(); }
// The following methods are responsible for updating information when it is changed. /// <summary> /// Updates the user control every time it is loaded. /// </summary> public void UpdateUserControl() { var eazyCartContext = new EazyCartContext(); this.cityBusiness = new CityBusiness(eazyCartContext); this.countryBusiness = new CountryBusiness(eazyCartContext); this.categoryBusiness = new CategoryBusiness(eazyCartContext); this.supplierBusiness = new SupplierBusiness(eazyCartContext); this.ClearAndUpdateCategoryTab(); this.ClearAndUpdateCountryTab(); this.ClearAndUpdateCityTab(); this.ClearAndUpdateSupplierTab(); }
public void Delete_SuccessfullyDeletesSupplier_WhenNoProductsAreRelatedToTheSupplier() { // Arrange var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1, CityId = 1 }, new Supplier { Name = "TestSupplier2", Id = 2, CityId = 1 } }.AsQueryable(); var products = new List <Product> { new Product { Name = "TestProduct1", SupplierId = 1 } }.AsQueryable(); var mockDbSupplierSet = new Mock <DbSet <Supplier> >(); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockDbProductSet = new Mock <DbSet <Product> >(); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.Provider).Returns(products.Provider); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.Expression).Returns(products.Expression); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.ElementType).Returns(products.ElementType); mockDbProductSet.As <IQueryable <Product> >().Setup(m => m.GetEnumerator()).Returns(products.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Suppliers).Returns(mockDbSupplierSet.Object); mockContext.Setup(c => c.Products).Returns(mockDbProductSet.Object); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act int idToDelete = 2; supplierBusiness.Delete(idToDelete); // Assert mockDbSupplierSet.Verify(m => m.Remove(It.IsAny <Supplier>()), Times.Once()); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
public void GetAll_ReturnsACorrectListOfSuppliers_WhenNotEmpty() { // Arrange var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1 }, new Supplier { Name = "TestSupplier2", Id = 2 }, new Supplier { Name = "TestSupplier3", Id = 3 } }.AsQueryable(); var supplierMockDbSet = new Mock <DbSet <Supplier> >(); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Suppliers).Returns(supplierMockDbSet.Object); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act var allSuppliers = supplierBusiness.GetAll(); // Assert string expectedFirstSupplierName = "TestSupplier1"; string expectedSecondSupplierName = "TestSupplier2"; string expectedThirdSupplierName = "TestSupplier3"; Assert.AreEqual(expectedFirstSupplierName, allSuppliers[0].Name, "First names do not match."); Assert.AreEqual(expectedSecondSupplierName, allSuppliers[1].Name, "Second names do not match."); Assert.AreEqual(expectedThirdSupplierName, allSuppliers[2].Name, "Third names do not match"); }
public void GetSupplier_ReturnsACorrectSupplier() { // Arrange var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1 }, new Supplier { Name = "TestSupplier2", Id = 2 }, new Supplier { Name = "TestSupplier3", Id = 3 } }.AsQueryable(); var supplierMockDbSet = new Mock <DbSet <Supplier> >(); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Suppliers).Returns(supplierMockDbSet.Object); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act int idToGet = 2; var supplier = supplierBusiness.Get(idToGet); // Assert string expectedSupplierName = "TestSupplier2"; Assert.IsNotNull(supplier, "Supplier could not be extracted."); Assert.AreEqual(expectedSupplierName, supplier.Name, "Names do not match."); }
public SupplierInfo GetSupplierInfo(string suppliercode) { SupplierInfo objSupplierInfo = new SupplierInfo(); List <SupplierAttachment> objSupplierAttachment = new List <SupplierAttachment>(); List <SupplierBusiness> objSupplierBusiness = new List <SupplierBusiness>(); List <SupplierContact> objSupplierContact = new List <SupplierContact>(); string vSupplierText = @"SELECT [SupplierCode] ,[SupplierID] ,[SupplierName] ,[Email] ,[MobileNumber] ,[EnlistmentDate] ,[SupplierAddress] ,[AlternateEmail] ,[ZipCode] ,[Fax] ,[IsApproved] ,[ApprovalAction] FROM [LSP_PMS_SupplierInfo] where SupplierCode = '" + suppliercode + "'"; string vAttachmentText = @"SELECT [AttachmentCode] ,[SupplierCode] ,[AttachmentName] ,[CertificateNumber] ,[IssueDate] ,[ExpiryDate] ,[FileLocationPath] ,[Remarks] FROM [LSP_PMS_SupplierDocuments] where SupplierCode = '" + suppliercode + "'"; string vContactText = @"SELECT [ContactPersonCode] ,[SupplierCode] ,[ContactName] ,[JobRole] ,[Email] ,[MobileNumber] ,[Designation] ,[TelephoneNumber] FROM [LSP_PMS_SupplierContact] where SupplierCode = '" + suppliercode + "'"; string vBusinessText = @"SELECT [SupplierCode] ,[BusinessTypeCode] ,filename FROM [LSP_PMS_SupplierBusiness] b join general_codefile f on b.[BusinessTypeCode]=f.filecode where SupplierCode = '" + suppliercode + "'"; SqlConnection connection = _supplierDbContext.GetConn(); connection.Open(); SqlCommand objDbCommand = new SqlCommand(vSupplierText, connection); using (SqlDataReader dr = objDbCommand.ExecuteReader()) { if (dr.Read()) { objSupplierInfo = new SupplierInfo(); objSupplierInfo.SupplierCode_PK = dr["SupplierCode"].ToString(); objSupplierInfo.SupplierID = dr["SupplierID"].ToString(); objSupplierInfo.SupplierName = dr["SupplierName"].ToString(); objSupplierInfo.Email = dr["Email"].ToString(); objSupplierInfo.MobileNumber = dr["MobileNumber"].ToString(); objSupplierInfo.EnlistmentDate = dr.GetDateTime(dr.GetOrdinal("EnlistmentDate")).ToString("dd-MM-yyyy"); objSupplierInfo.SupplierAddress = dr["SupplierAddress"].ToString(); objSupplierInfo.AlternateEmail = dr["AlternateEmail"].ToString(); objSupplierInfo.ZipCode = dr["ZipCode"].ToString(); objSupplierInfo.Fax = dr["Fax"].ToString(); objSupplierInfo.IsApproved = Convert.ToInt16(dr["IsApproved"].ToString()); objSupplierInfo.ApprovalAction = Convert.ToInt16(dr["ApprovalAction"].ToString()); } } SqlCommand objDbCommandAttachment = new SqlCommand(vAttachmentText, connection); using (SqlDataReader dr = objDbCommandAttachment.ExecuteReader()) { while (dr.Read()) { SupplierAttachment supplierAttachment = new SupplierAttachment(); supplierAttachment.AttachmentCode_PK = dr["AttachmentCode"].ToString(); supplierAttachment.SupplierCode_FK = dr["SupplierCode"].ToString(); supplierAttachment.AttachmentName = dr["AttachmentName"].ToString(); supplierAttachment.CertificateNumber = dr["CertificateNumber"].ToString(); if (!string.IsNullOrEmpty(dr["IssueDate"].ToString())) { supplierAttachment.IssueDate = dr.GetDateTime(dr.GetOrdinal("IssueDate")).ToString("dd-MM-yyyy"); } if (!string.IsNullOrEmpty(dr["ExpiryDate"].ToString())) { supplierAttachment.ExpiryDate = dr.GetDateTime(dr.GetOrdinal("ExpiryDate")).ToString("dd-MM-yyyy"); } supplierAttachment.FileLocationPath = dr["FileLocationPath"].ToString(); supplierAttachment.Remarks = dr["Remarks"].ToString(); objSupplierAttachment.Add(supplierAttachment); } } SqlCommand objDbCommandBusiness = new SqlCommand(vBusinessText, connection); using (SqlDataReader dr = objDbCommandBusiness.ExecuteReader()) { while (dr.Read()) { SupplierBusiness supplierBusiness = new SupplierBusiness(); supplierBusiness.SupplierCode_FK = dr["SupplierCode"].ToString(); supplierBusiness.BusinessTypeCode_PK = Convert.ToInt16(dr["BusinessTypeCode"].ToString()); supplierBusiness.filename_VW = dr["filename"].ToString(); objSupplierBusiness.Add(supplierBusiness); } } SqlCommand objDbCommandContact = new SqlCommand(vContactText, connection); using (SqlDataReader dr = objDbCommandContact.ExecuteReader()) { while (dr.Read()) { SupplierContact supplierContact = new SupplierContact(); supplierContact.SupplierCode_FK = dr["SupplierCode"].ToString(); supplierContact.ContactPersonCode_PK = dr["ContactPersonCode"].ToString(); supplierContact.ContactName = dr["ContactName"].ToString(); supplierContact.JobRole = dr["JobRole"].ToString(); supplierContact.Email = dr["Email"].ToString(); supplierContact.MobileNumber = dr["MobileNumber"].ToString(); supplierContact.Designation = dr["Designation"].ToString(); supplierContact.TelephoneNumber = dr["TelephoneNumber"].ToString(); objSupplierContact.Add(supplierContact); } } objSupplierInfo.SupplierAttachmentList_VW = objSupplierAttachment; objSupplierInfo.SupplierBusinessList_VW = objSupplierBusiness; objSupplierInfo.SupplierContactList_VW = objSupplierContact; return(objSupplierInfo); }
public void Update_ThrowsArgumentException_WhenInformationIsNotValid() { // Arrange var countries = new List <Country> { new Country { Name = "TestCountry1", Id = 1 } }.AsQueryable(); var cities = new List <City> { new City { Name = "TestCity1", Id = 1, CountryId = 1 } }.AsQueryable(); var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1, CityId = 1 } }.AsQueryable(); var mockDbCountrySet = new Mock <DbSet <Country> >(); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator()); var mockDbCitySet = new Mock <DbSet <City> >(); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.Provider).Returns(cities.Provider); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.Expression).Returns(cities.Expression); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.ElementType).Returns(cities.ElementType); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.GetEnumerator()).Returns(cities.GetEnumerator()); var mockDbSupplierSet = new Mock <DbSet <Supplier> >(); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Cities).Returns(mockDbCitySet.Object); mockContext.Setup(c => c.Countries).Returns(mockDbCountrySet.Object); mockContext.Setup(c => c.Suppliers).Returns(mockDbSupplierSet.Object); mockContext.Setup(c => c.SaveChanges()).Throws(new Exception()); var supplierBusiness = new SupplierBusiness(mockContext.Object); // Act & Assert try { supplierBusiness.Update("TestSupplier1", 1, "InvalidCountry", "InvalidCity"); Assert.Fail("No exception was thrown"); } catch (Exception ex) { string expectedMessage = string.Format("No such country/city exists."); Assert.AreEqual(expectedMessage, ex.Message, "Wrong exception was thrown."); } }
public void Add_ThrowsArgumentException_WhenSupplierWithIdAlreadyExists() { // Arrange var countries = new List <Country> { new Country { Name = "TestCountry1", Id = 1 } }.AsQueryable(); var cities = new List <City> { new City { Name = "TestCity1", Id = 1, CountryId = 1 } }.AsQueryable(); var suppliers = new List <Supplier> { new Supplier { Name = "TestSupplier1", Id = 1, CityId = 1 } }.AsQueryable(); var mockDbCountrySet = new Mock <DbSet <Country> >(); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType); mockDbCountrySet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator()); var mockDbCitySet = new Mock <DbSet <City> >(); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.Provider).Returns(cities.Provider); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.Expression).Returns(cities.Expression); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.ElementType).Returns(cities.ElementType); mockDbCitySet.As <IQueryable <City> >().Setup(m => m.GetEnumerator()).Returns(cities.GetEnumerator()); var mockDbSupplierSet = new Mock <DbSet <Supplier> >(); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType); mockDbSupplierSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Cities).Returns(mockDbCitySet.Object); mockContext.Setup(c => c.Countries).Returns(mockDbCountrySet.Object); mockContext.Setup(c => c.Suppliers).Returns(mockDbSupplierSet.Object); mockContext.Setup(c => c.SaveChanges()).Throws(new Exception()); var supplierBusiness = new SupplierBusiness(mockContext.Object); int duplicateId = 1; // Act & Assert try { supplierBusiness.Add("TestSupplier1", 1, "TestCity1", "TestCountry1"); supplierBusiness.Add("TestSupplier2", 1, "TestCity1", "TestCountry1"); Assert.Fail("No exception was thrown"); } catch (ArgumentException ex) { string expectedMessage = string.Format($"Supplier with ID {duplicateId} already exists."); Assert.AreEqual(expectedMessage, ex.Message, "Wrong exception was thrown."); } }