public void setup() { Supplier testSupplier = new Supplier(); testSupplier = new Supplier(); testSupplier.CompanyName = "fakeCompany"; testSupplier.FirstName = "FakeLogin"; testSupplier.LastName = "FakeLogin"; testSupplier.Address1 = "255 East West St"; testSupplier.Address2 = "APT 1"; testSupplier.Zip = "50229"; testSupplier.PhoneNumber = "575-542-8796"; testSupplier.EmailAddress = "*****@*****.**"; testSupplier.ApplicationID = 999; testSupplier.SupplyCost = (decimal)((60) / 100); testSupplier.Active = true; SupplierAccessor.AddSupplier(testSupplier, "Test", "Password#1"); try { var supList = SupplierAccessor.GetSupplierList(); foreach (Supplier x in supList) { if (x.FirstName.Equals("FirstBlab")) { suppID = x.SupplierID; } } } catch (Exception ex) { throw new Exception("what"); } }
/// <summary> /// Reece Maas /// Created: 2015/02/18 /// Adds a single Supplier to the database /// Throws any exceptions caught by the DAL /// </summary> /// <remarks> /// Matt Lapka /// Updated: 2015/03/27 /// Added supplier cache /// </remarks> /// <param name="supplierToAdd">Supplier object containing the information of the supplier to be added</param> /// <param name="userName">The username to be given to the Supplier</param> /// <returns>An enumerated result depicting pass or fail</returns> public SupplierResult AddANewSupplier(Supplier supplierToAdd, string userName) { try { PasswordManager myPass = new PasswordManager(); string password = myPass.supplierHash(userName, "Password#1"); if (SupplierAccessor.AddSupplier(supplierToAdd, userName, password) == 2) { //refresh cache DataCache._currentSupplierList = SupplierAccessor.GetSupplierList(); DataCache._SupplierListTime = DateTime.Now; return(SupplierResult.Success); } return(SupplierResult.NotAdded); } catch (ApplicationException ex) { return(ex.Message == "Concurrency Violation" ? SupplierResult.ChangedByOtherUser : SupplierResult.DatabaseError); } catch (Exception ex) { throw ex; //return SupplierResult.DatabaseError; } }
public void AddItemListing_ValidItemListing() { int expected = 1; setup(); SupplierAccessor.AddSupplier(testSupp, "Test", "Password#1"); modSupp = getSupplierListCompName(suppList); itemListingToTest.SupplierID = modSupp.SupplierID; int actual = ItemListingAccessor.AddItemListing(itemListingToTest); ItemListingAccessor.DeleteItemListingTestItem(itemListingToTest); testSupp.SupplierID = modSupp.SupplierID; testLog = sLA.RetrieveSupplierLogin("Password#1", "Test"); SupplierLoginAccessor.DeleteTestSupplierLogin(testLog); TestCleanupAccessor.DeleteTestSupplier(testSupp); Assert.AreEqual(expected, actual); }