// Making a product (and puts them into a list) from every line in the file products.csv public void GetAllUsers() { ReadingFiles usersFile = new ReadingFiles(); List <string[]> users = usersFile.ReadingUsersFile(); foreach (string[] userLine in users) { int intTemp; int iD; decimal balance; if (int.TryParse(userLine[0], out intTemp)) { iD = intTemp; } else { throw new ParseFailedException("Could not parse string to int"); } string firstname = userLine[1].Replace("\"", ""); string lastname = userLine[2].Replace("\"", ""); string username = userLine[3].Replace("\"", ""); string email = userLine[4].Replace("\"", ""); balance = decimal.Parse(userLine[5], NumberStyles.Any, CultureInfo.InvariantCulture); // Making the list of products _listOfUsers.Add(new User(iD, firstname, lastname, username, email, balance)); } }
public void Test_ReadingProducsFile_Length_ShouldFail() { ReadingFiles readingFiles = new ReadingFiles(); Assert.AreNotEqual (133, readingFiles.ReadProductsFile().Count); }
// Making a product (and puts them into a list) from every line in the file products.csv public void GetAllProducts() { ReadingFiles productsFile = new ReadingFiles(); List <string[]> products = productsFile.ReadProductsFile(); foreach (string[] productLine in products) { int intTemp; int iD; bool active; if (int.TryParse(productLine[0], out intTemp)) { iD = intTemp; } else { throw new ParseFailedException("Could not parse string to int"); } string name = productsFile.RemoveHTMLCode(productLine[1]).Trim(); // Dividing with 100 because the input was not in whole KR, but in ØRE decimal price = (decimal.Parse(productLine[2], NumberStyles.Any, CultureInfo.InvariantCulture) / 100); if (productLine[3] == "1") { active = true; } else { active = false; } // Making the list of products _listOfProducts.Add(new Product(iD, name, price, active)); } }
public void Test_ReadingUsersFile_Length_ShouldFail() { ReadingFiles readingFiles = new ReadingFiles(); Assert.AreNotEqual(59, readingFiles.ReadingUsersFile().Count); }
public void Test_ReadingUsersFile_Length_ShouldPass() { ReadingFiles readingFiles = new ReadingFiles(); Assert.AreEqual(60, readingFiles.ReadingUsersFile().Count); }