public void MakeTransactionList_ReturnsTwoTransactionsForTwoProducts() { List <Product> products = new List <Product>(); products.Add(new Product(1, "water", 40, 1)); products.Add(new Product(2, "salt", 100, 2)); var user1 = new User(); var user2 = new User(); user1.UserName = "******"; user2.UserName = "******"; products[0].ProductUsers = new List <ProductUser>(); products[0].ProductUsers.Add(new ProductUser(user1, products[0])); products[1].ProductUsers = new List <ProductUser>(); products[1].ProductUsers.Add(new ProductUser(user2, products[1])); products[0].ProductUsers[0].User = user1; products[1].ProductUsers[0].User = user2; products[0].Check = new Check(user1); products[1].Check = products[0].Check; TransactionEqualityComparer transactionEqualityComparer = new TransactionEqualityComparer(); var expectedTransaction = new List <Transaction>(); expectedTransaction.Add(new Transaction("user1", "user1", 40)); expectedTransaction.Add(new Transaction("user2", "user1", 200)); var actualTransactions = Transaction.MakeTransactionList(products); Assert.Equal(expectedTransaction, actualTransactions, transactionEqualityComparer); }
public void MakeTransactionList_ReturnsOneTransaction() { List <Product> products = new List <Product>(); products.Add(new Product(1, "water", 40, 1)); var user = new User(); user.UserName = "******"; products[0].ProductUsers = new List <ProductUser>(); products[0].ProductUsers.Add(new ProductUser(user, products[0])); products[0].ProductUsers[0].User = user; products[0].Check = new Check(user); TransactionEqualityComparer transactionEqualityComparer = new TransactionEqualityComparer(); var expectedTransaction = new List <Transaction>(); expectedTransaction.Add(new Transaction("test", "test", 40)); var actualTransactions = Transaction.MakeTransactionList(products); Assert.Equal(expectedTransaction, actualTransactions, transactionEqualityComparer); }