-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
276f923
commit 14509bc
Showing
4 changed files
with
88 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,9 @@ public MockOrderDAO() | |
{ | ||
var users = new List<Customer> | ||
{ | ||
new Customer { Id = 1, FirstName = "Alice", LastName = "Johnson", Address="Sofia", NutriPoints = 60 }, | ||
new Customer { Id = 2, FirstName = "Bob", LastName = "Smith", NutriPoints = 15 }, | ||
new Customer { Id = 3, FirstName = "John", LastName = "Doe", NutriPoints = 100 } | ||
new Customer ( id: 1, firstName: "Alice", lastName: "Johnson", email: "[email protected]", passwordHash: "hash", passwordSalt: "salt", address: "Sofia", nutriPoints: 60), | ||
new Customer ( id: 2, firstName: "Bob", lastName: "Smith", email: "[email protected]", passwordHash: "hash", passwordSalt: "salt", address: "USA", nutriPoints: 15), | ||
new Customer ( id: 3, firstName: "John", lastName: "Doe", email: "[email protected]", passwordHash: "hash", passwordSalt: "salt", address: "England", nutriPoints: 100) | ||
}; | ||
|
||
var products = new List<ProductModel> | ||
|
@@ -71,13 +71,16 @@ public MockOrderDAO() | |
} | ||
|
||
|
||
public bool CreateOrder(Order order) | ||
{ | ||
orders.Add(order); | ||
order.Customer.NutriPoints += order.Cart.NutriPointsReward; | ||
order.Customer.NutriPoints -= order.Cart.NutriPointsNeeded; | ||
return true; | ||
} | ||
//public bool CreateOrder(Order order) | ||
//{ | ||
// orders.Add(order); | ||
// order.Customer = new Customer(); | ||
|
||
// order.Customer.NutriPoints += order.Cart.NutriPointsReward; | ||
// order.Customer.NutriPoints -= order.Cart.NutriPointsNeeded; | ||
|
||
// return order; | ||
//} | ||
|
||
public ShoppingCart GetShoppingCart(int id) | ||
{ | ||
|
@@ -118,6 +121,20 @@ public Dictionary<int, Dictionary<ProductModel, int>> GetRecommendations(int cus | |
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
|
||
public bool CreateOrder(Order order) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public ProductModel GetMerchantRecommendation(int customerId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool CreateMerchantRecommendation(int customerId, ProductModel newProduct) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using Models.User.Enums; | ||
using NUnit.Framework; | ||
using Services; | ||
using Services.Sort; | ||
using System.Data; | ||
|
||
namespace FitFusionTest | ||
|
@@ -23,28 +24,30 @@ public void SetUp() | |
public void CreateUser_DuplicateEmail_ShouldThrowDuplicateNameException() | ||
{ | ||
var existingUser = new Owner | ||
{ | ||
FirstName = "Peter", | ||
LastName = "Parker", | ||
Email = "[email protected]", | ||
PasswordHash = "[email protected]", | ||
PasswordSalt = "salt", | ||
Address = "USA", | ||
Phone = "1234567890", | ||
}; | ||
( | ||
id: 24, | ||
firstName: "Peter", | ||
lastName: "Parker", | ||
email: "[email protected]", | ||
passwordHash: "[email protected]", | ||
passwordSalt: "salt", | ||
address: "USA", | ||
phone: "1234567890" | ||
); | ||
|
||
_dao.CreateUser(existingUser); | ||
|
||
var newUser = new Customer | ||
{ | ||
FirstName = "Peter", | ||
LastName = "Parker", | ||
Email = "[email protected]", | ||
PasswordHash = "[email protected]", | ||
PasswordSalt = "salt", | ||
Address = "USA", | ||
NutriPoints = 0 | ||
}; | ||
( | ||
id: 24, | ||
firstName: "Peter", | ||
lastName: "Parker", | ||
email: "[email protected]", | ||
passwordHash: "[email protected]", | ||
passwordSalt: "salt", | ||
address: "USA", | ||
nutriPoints: 0 | ||
); | ||
|
||
Assert.Throws<DuplicateNameException>(() => _manager.CreateUser(newUser)); | ||
} | ||
|
@@ -53,30 +56,30 @@ public void CreateUser_DuplicateEmail_ShouldThrowDuplicateNameException() | |
public void UpdateUser_ExistingUser_ShouldUpdateUser() | ||
{ | ||
var existingUser = new Customer | ||
{ | ||
Id = 1, | ||
FirstName = "Ivan", | ||
LastName = "Ivanov", | ||
Email = "[email protected]", | ||
PasswordHash = "[email protected]", | ||
PasswordSalt = "salt", | ||
Address = "USA", | ||
NutriPoints = 0 | ||
}; | ||
( | ||
id: 23, | ||
firstName: "Ivan", | ||
lastName: "Ivanov", | ||
email: "[email protected]", | ||
passwordHash: "[email protected]", | ||
passwordSalt: "salt", | ||
address: "USA", | ||
nutriPoints: 0 | ||
); | ||
|
||
_dao.CreateUser(existingUser); | ||
|
||
var updatedUser = new Customer | ||
{ | ||
Id = 1, | ||
FirstName = "Ivan", | ||
LastName = "Parker", | ||
Email = "[email protected]", | ||
PasswordHash = "[email protected]", | ||
PasswordSalt = "salt", | ||
Address = "Bulgaria", | ||
NutriPoints = 0 | ||
}; | ||
( | ||
id: 23, | ||
firstName: "Ivan", | ||
lastName: "Parker", | ||
email: "[email protected]", | ||
passwordHash: "[email protected]", | ||
passwordSalt: "salt", | ||
address: "Bulgaria", | ||
nutriPoints: 0 | ||
); | ||
|
||
_manager.UpdateUser(updatedUser); | ||
|
||
|
@@ -93,16 +96,16 @@ public void UpdateUser_ExistingUser_ShouldUpdateUser() | |
public void DeleteUser_ExistingUser_ShouldRemoveUser() | ||
{ | ||
var existingUser = new Customer | ||
{ | ||
Id = 1, | ||
FirstName = "Doom", | ||
LastName = "Doctor", | ||
Email = "[email protected]", | ||
PasswordHash = "[email protected]", | ||
PasswordSalt = "salt", | ||
Address = "USA", | ||
NutriPoints = 0 | ||
}; | ||
( | ||
id: 1, | ||
firstName: "Doom", | ||
lastName: "Doctor", | ||
email: "[email protected]", | ||
passwordHash: "[email protected]", | ||
passwordSalt: "salt", | ||
address: "USA", | ||
nutriPoints: 0 | ||
); | ||
|
||
_dao.CreateUser(existingUser); | ||
|
||
|
@@ -151,7 +154,7 @@ public void Sort_ShouldSortUsersByLastNameInDescendingOrder() | |
List<User> users = _manager.GetAllUsers(); | ||
|
||
List<User> usersToCompare = users.OrderByDescending(x => x.LastName).ToList(); | ||
List<User> usersToCheck = _manager.Sort(users, SortParameter.LastNameDescending); | ||
List<User> usersToCheck = _manager.Sort(users, new LastNameDescending()); | ||
|
||
Assert.That(usersToCheck, Is.EqualTo(usersToCompare)); | ||
} | ||
|