Files

94 lines
2.7 KiB
C#
Raw Permalink Normal View History

2023-12-06 23:32:06 +01:00
using NUnit.Framework;
2023-12-06 23:45:02 +01:00
using WD7UVN_HFT_2023241.Models;
using WD7UVN_HFT_2023241.Logic;
using WD7UVN_HFT_2023241.Repository;
2023-12-12 10:28:50 +01:00
using System.Collections.Generic;
using System.Linq;
2023-12-06 23:32:06 +01:00
namespace WD7UVN_HFT_2023241.Test
{
2023-12-12 11:10:51 +01:00
public class CreateTests
2023-12-06 23:32:06 +01:00
{
2023-12-12 11:10:28 +01:00
LogicServices logic;
2023-12-12 10:28:50 +01:00
2023-12-06 23:32:06 +01:00
[SetUp]
public void Setup()
{
2023-12-12 11:10:28 +01:00
logic = new LogicServices(new CRUD());
2023-12-13 12:12:20 +01:00
Database.Context = new CompanyDbContext();
2023-12-06 23:32:06 +01:00
}
[Test]
2023-12-12 10:28:50 +01:00
public void CreateCustomerTest()
2023-12-06 23:32:06 +01:00
{
2023-12-12 11:10:28 +01:00
var testData = logic.CRUDOperations.ReadAllCustomers();
List<Customer> tmp = new List<Customer>(testData);
Customer s = new Customer()
{
ID = 10,
NAME = "Testing Hungary Kft."
};
tmp.Add(s);
testData.Concat(tmp.AsQueryable());
logic.CRUDOperations.CreateCustomer(s);
Assert.That(logic.CRUDOperations.ReadAllCustomers() == testData);
}
[Test]
public void CreateEmployeeTest()
{
var testData = logic.CRUDOperations.ReadAllEmployees();
List<Employee> tmp = new List<Employee>(testData);
Employee s = new Employee()
{
ID = 10,
NAME = "Teszt Vilmos"
};
tmp.Add(s);
testData.Concat(tmp.AsQueryable());
logic.CRUDOperations.CreateEmployee(s);
Assert.That(logic.CRUDOperations.ReadAllEmployees() == testData);
}
2023-12-12 10:28:50 +01:00
2023-12-12 11:10:28 +01:00
[Test]
public void CreateServiceTest()
{
var testData = logic.CRUDOperations.ReadAllServices();
List<Service> tmp = new List<Service>(testData);
Service s = new Service()
{
ID = 10,
NAME = "System testing"
};
tmp.Add(s);
testData.Concat(tmp.AsQueryable());
logic.CRUDOperations.CreateService(s);
Assert.That(logic.CRUDOperations.ReadAllServices() == testData);
}
[Test]
public void CreateMaintainerTeamTest()
{
var testData = logic.CRUDOperations.ReadAllMaintainerTeams();
List<MaintainerTeam> tmp = new List<MaintainerTeam>(testData);
MaintainerTeam s = new MaintainerTeam()
{
ID = 10,
NAME = "Tesztelő csapat"
};
tmp.Add(s);
testData.Concat(tmp.AsQueryable());
logic.CRUDOperations.CreateMaintainerTeam(s);
Assert.That(logic.CRUDOperations.ReadAllMaintainerTeams() == testData);
2023-12-06 23:32:06 +01:00
}
}
2023-12-12 10:28:50 +01:00
}