QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
172 lines
7.5 KiB
C#
172 lines
7.5 KiB
C#
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.MyDay;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Interfaces.MyDay;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
using Centron.Interfaces.BL;
|
|
using CentronSoftware.Centron.WebServices.Entities.MyDay;
|
|
using Centron.BusinessLogic.Administration.Employees;
|
|
using Centron.BusinessLogic.WebServices.Employee;
|
|
using Centron.BusinessLogic.EmployeeArea;
|
|
using Centron.Data.Entities.EmployeeArea;
|
|
using Microsoft.Graph.Models.Security;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.MyDay
|
|
{
|
|
public class MyDayNotificationsTest : EndToEndTest
|
|
{
|
|
public MyDayNotificationsTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
private DateTime GetDateTime()
|
|
{
|
|
var date = DateTime.Today.AddDays(-1);
|
|
|
|
while (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
|
|
{
|
|
date = date.AddDays(-1);
|
|
}
|
|
|
|
return date;
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PrepareDatabase(this.GetLoggedInUser());
|
|
this.CheckFinalizeMyDayNotifications(this.GetLoggedInUser(), 1); // Expected: Beside vacation and sicckness has also work item "Meeting" and no finalized day -> Notification
|
|
|
|
this.UpdateDatabase(this.GetLoggedInUser(34));
|
|
this.CheckFinalizeMyDayNotifications(this.GetLoggedInUser(34), 0); // Expected: Only items for vacation and sickness -> No Notification
|
|
|
|
// Addes test case for Ticket 157349
|
|
// Before: MyDayFinalizedDay was only recognized if it was saved between 0:00:00 and 23:59:59 on the last working day.
|
|
// Now: MyDayFinalizedDay is recognized when it is saved between 0:00:00 a.m. on the last working day and immediately before the notification check.
|
|
this.LateFinalizeMyDayBooking(this.GetLoggedInUser());
|
|
this.CheckFinalizeMyDayNotifications(this.GetLoggedInUser(), 0); // Expcted: Finalized day just in time for the work item "Meeting" -> No Notification
|
|
}
|
|
|
|
private void PrepareDatabase(LoggedInUser loggedInUser)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var settings = session.GetBL<MyDayWebServiceBL>().GetSettings().ThrowIfError();
|
|
settings.SendDayNotFinalizedNotifications = true;
|
|
session.GetBL<MyDayWebServiceBL>().UpdateSettings(settings).ThrowIfError();
|
|
|
|
session.GetBL<MyDayWebServiceBL>().SaveOrUpdateWorkItem(new MyDayWorkItemDTO
|
|
{
|
|
StartTime = this.GetDateTime().AddHours(8),
|
|
EndTime = this.GetDateTime().AddHours(17),
|
|
BreakTime = TimeSpan.FromHours(1),
|
|
EmployeeI3D = loggedInUser.User.Employee.I3D,
|
|
Caption = "Sickness",
|
|
Type = MyDayWorkItemType.Sickness,
|
|
ShowInTimeLine = true
|
|
}).ThrowIfError();
|
|
|
|
session.GetBL<MyDayWebServiceBL>().SaveOrUpdateWorkItem(new MyDayWorkItemDTO
|
|
{
|
|
StartTime = this.GetDateTime().AddHours(8),
|
|
EndTime = this.GetDateTime().AddHours(17),
|
|
BreakTime = TimeSpan.FromHours(1),
|
|
EmployeeI3D = loggedInUser.User.Employee.I3D,
|
|
Caption = "Vacation",
|
|
Type = MyDayWorkItemType.Vacation,
|
|
ShowInTimeLine = true
|
|
}).ThrowIfError();
|
|
|
|
session.GetBL<MyDayWebServiceBL>().SaveOrUpdateWorkItem(new MyDayWorkItemDTO
|
|
{
|
|
StartTime = this.GetDateTime().AddHours(8),
|
|
EndTime = this.GetDateTime().AddHours(17),
|
|
BreakTime = TimeSpan.FromHours(1),
|
|
EmployeeI3D = loggedInUser.User.Employee.I3D,
|
|
Caption = "Meeting",
|
|
Type = MyDayWorkItemType.Meeting,
|
|
ShowInTimeLine = true
|
|
}).ThrowIfError();
|
|
|
|
var result = session.GetBL<EmployeeDepartmentBL>().GetEmployeeDepartments2(loggedInUser.User).ThrowIfError();
|
|
|
|
var employeeDepartment = result.FirstOrDefault();
|
|
employeeDepartment.MyDayBegin = this.GetDateTime().AddHours(8);
|
|
employeeDepartment.IsMyDayActive = true;
|
|
|
|
session.GetBL<EmployeeDepartmentBL>().UpdateEmployeeDepartments(loggedInUser.User, result).ThrowIfError();
|
|
}
|
|
}
|
|
|
|
private void UpdateDatabase(LoggedInUser loggedInUser)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var settings = session.GetBL<MyDayWebServiceBL>().GetSettings().ThrowIfError();
|
|
settings.SendDayNotFinalizedNotifications = true;
|
|
session.GetBL<MyDayWebServiceBL>().UpdateSettings(settings).ThrowIfError();
|
|
|
|
session.GetBL<MyDayWebServiceBL>().SaveOrUpdateWorkItem(new MyDayWorkItemDTO
|
|
{
|
|
StartTime = this.GetDateTime().AddHours(8),
|
|
EndTime = this.GetDateTime().AddHours(17),
|
|
BreakTime = TimeSpan.FromHours(1),
|
|
EmployeeI3D = loggedInUser.User.Employee.I3D,
|
|
Caption = "Sickness",
|
|
Type = MyDayWorkItemType.Sickness,
|
|
ShowInTimeLine = true
|
|
}).ThrowIfError();
|
|
|
|
session.GetBL<MyDayWebServiceBL>().SaveOrUpdateWorkItem(new MyDayWorkItemDTO
|
|
{
|
|
StartTime = this.GetDateTime().AddHours(8),
|
|
EndTime = this.GetDateTime().AddHours(17),
|
|
BreakTime = TimeSpan.FromHours(1),
|
|
EmployeeI3D = loggedInUser.User.Employee.I3D,
|
|
Caption = "Vacation",
|
|
Type = MyDayWorkItemType.Vacation,
|
|
ShowInTimeLine = true
|
|
}).ThrowIfError();
|
|
|
|
var result = session.GetBL<EmployeeDepartmentBL>().GetEmployeeDepartments2(loggedInUser.User).ThrowIfError();
|
|
|
|
var employeeDepartment = result.FirstOrDefault();
|
|
employeeDepartment.MyDayBegin = this.GetDateTime().AddHours(8);
|
|
employeeDepartment.IsMyDayActive = true;
|
|
|
|
session.GetBL<EmployeeDepartmentBL>().UpdateEmployeeDepartments(loggedInUser.User, result).ThrowIfError();
|
|
}
|
|
}
|
|
|
|
private void CheckFinalizeMyDayNotifications(LoggedInUser loggedInUser, int expectedNotificationCount)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var notifications = session.GetBL<MyDayNotificationsWebServiceBL>().GetCurrentNotificationsToSend();
|
|
|
|
Assert.True(notifications.Where(f => f.EmployeeI3D == loggedInUser.User.Employee.I3D).Count() == expectedNotificationCount);
|
|
}
|
|
}
|
|
|
|
|
|
private void LateFinalizeMyDayBooking(LoggedInUser loggedInUser)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<MyDayWebServiceBL>().SaveOrUpdateFinalizedDay(new MyDayFinalizedDayDTO
|
|
{
|
|
EmployeeI3D = loggedInUser.User.Employee.I3D,
|
|
Date = DateTime.Now.AddMinutes(-1),
|
|
Comment = "Sorry forgot to do that yesterday!"
|
|
}).ThrowIfError();
|
|
}
|
|
}
|
|
}
|
|
}
|