Wrote first test

This commit is contained in:
2023-12-12 10:28:50 +01:00
parent 29d702448d
commit 1389595d89

View File

@@ -3,20 +3,56 @@ using WD7UVN_HFT_2023241.Models;
using WD7UVN_HFT_2023241.Logic; using WD7UVN_HFT_2023241.Logic;
using WD7UVN_HFT_2023241.Repository; using WD7UVN_HFT_2023241.Repository;
using Moq; using Moq;
using System.Collections.Generic;
using System.Linq;
namespace WD7UVN_HFT_2023241.Test namespace WD7UVN_HFT_2023241.Test
{ {
public class Tests public class Tests
{ {
Mock<ICRUD> mockCRUD;
LogicServices logic;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
var data = new List<Customer>()
{
new Customer
{
NAME = "Szemed Fénye Optika Kft.",
ID = 1,
EMAIL = "info@szemedfenye.hu",
PHONE = "+36 30 123 4567",
SERVICE_ID = 1
},
new Customer{
NAME = "DoBox Logisztika Kft.",
ID = 2,
EMAIL = "info@dobox.hu",
PHONE = "+36 50 234 5678",
SERVICE_ID = 2
}
}.AsQueryable();
mockCRUD = new Mock<ICRUD>();
mockCRUD.Setup(p => p.ReadAllCustomers()).Returns(data);
logic = new LogicServices(mockCRUD.Object);
} }
[Test] [Test]
public void Test1() public void CreateCustomerTest()
{ {
Assert.Pass(); Customer c = new Customer()
{
NAME = "Teszt Kft.",
ID = 3
};
logic.CRUDOperations.CreateCustomer(c);
mockCRUD.Verify(p => p.CreateCustomer(c), Times.Once);
} }
} }
} }