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
333 lines
10 KiB
C#
333 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Centron.BusinessLogic.TaskManager;
|
|
using Centron.Data.Entities.TaskManager.Recurrences;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.TaskManagementRecurrence
|
|
{
|
|
public class TaskManagementRecurrenceTest : CentronTest
|
|
{
|
|
public TaskManagementRecurrenceTest(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
this.Verifier.Settings.CleanupDateTimeValues = false;
|
|
}
|
|
|
|
[Fact]
|
|
public void Daily_EveryWeekday()
|
|
{
|
|
var startTime = new DateTime(2020, 9, 11);
|
|
|
|
var recurrence = new TaskManagementDailyRecurrence
|
|
{
|
|
StartTime = startTime,
|
|
EveryWeekday = true
|
|
};
|
|
|
|
this.VerifyDates("Daily_EveryWeekday", recurrence, startTime);
|
|
}
|
|
|
|
[Fact]
|
|
public void Daily_Every1Days()
|
|
{
|
|
var startTime = new DateTime(2020, 9, 11);
|
|
|
|
var recurrence = new TaskManagementDailyRecurrence
|
|
{
|
|
StartTime = startTime,
|
|
DayInterval = 1,
|
|
};
|
|
|
|
this.VerifyDates("Daily_Every1Day", recurrence, startTime);
|
|
}
|
|
|
|
[Fact]
|
|
public void Daily_Every2Days()
|
|
{
|
|
var startTime = new DateTime(2020, 9, 11);
|
|
|
|
var recurrence = new TaskManagementDailyRecurrence
|
|
{
|
|
StartTime = startTime,
|
|
DayInterval = 2,
|
|
};
|
|
|
|
this.VerifyDates("Daily_Every2Days", recurrence, startTime);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public void Weekly_Every1WeekOnMonday()
|
|
{
|
|
var startTime = new DateTime(2020, 9, 14);
|
|
|
|
var recurrence = new TaskManagementWeeklyRecurrence
|
|
{
|
|
StartTime = startTime,
|
|
EveryNWeeks = 1,
|
|
Days = new List<TaskManagementRecurrenceWeekDays>
|
|
{
|
|
new TaskManagementRecurrenceWeekDays
|
|
{
|
|
WeekDay = DayOfWeek.Monday
|
|
}
|
|
}
|
|
};
|
|
|
|
this.VerifyDates("Weekly_Every1WeekOnMonday", recurrence, startTime);
|
|
}
|
|
|
|
[Fact]
|
|
public void Weekly_Every2WeeksOnMondayTuesdayAndWednesday()
|
|
{
|
|
var startTime = new DateTime(2020, 9, 14);
|
|
|
|
var recurrence = new TaskManagementWeeklyRecurrence
|
|
{
|
|
StartTime = startTime,
|
|
EveryNWeeks = 2,
|
|
Days = new List<TaskManagementRecurrenceWeekDays>
|
|
{
|
|
new TaskManagementRecurrenceWeekDays
|
|
{
|
|
WeekDay = DayOfWeek.Monday,
|
|
},
|
|
new TaskManagementRecurrenceWeekDays
|
|
{
|
|
WeekDay = DayOfWeek.Tuesday,
|
|
},
|
|
new TaskManagementRecurrenceWeekDays
|
|
{
|
|
WeekDay = DayOfWeek.Wednesday,
|
|
}
|
|
}
|
|
};
|
|
|
|
this.VerifyDates("Weekly_Every2WeeksOnMondayTuesdayAndWednesday", recurrence, startTime);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public void Monthly_EveryMonthOnTheTenthDay()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 1,
|
|
DayOfMonth = 10,
|
|
};
|
|
|
|
this.VerifyDates("Monthly_EveryMonthOnTheTenthDay", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_EveryMonthOnThe30thDay()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 1,
|
|
DayOfMonth = 30,
|
|
};
|
|
|
|
this.VerifyDates("Monthly_EveryMonthOnThe30thDay", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_Every2MonthsOnThe20thDay()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 2,
|
|
DayOfMonth = 20,
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every2MonthsOnThe20thDay", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_EveryMonthOnTheFirstMonday()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 1,
|
|
WeekDay = DayOfWeek.Monday,
|
|
WeekInterval = 1
|
|
};
|
|
|
|
this.VerifyDates("Monthly_EveryMonthOnTheFirstMonday", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_Every2MonthsOnTheLastFriday()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 2,
|
|
WeekDay = DayOfWeek.Friday,
|
|
WeekInterval = 5,
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every2MonthsOnTheLastFriday", recurrence, startDate);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public void Monthly_Every3MonthsOnTheFirstMonday()
|
|
{
|
|
// Ticket 168438 / 167839: "first weekday of every Nth month" (WeekOfMonth.First + MonthInterval > 1)
|
|
// regressed to an effective N*N-month step (3 -> 9). Customer contract 14077 starts on the first
|
|
// Monday in October 2025 and should recur strictly every 3 months.
|
|
var startDate = new DateTime(2025, 10, 6);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 3,
|
|
WeekDay = DayOfWeek.Monday,
|
|
WeekInterval = 1, // WeekOfMonth.First
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every3MonthsOnTheFirstMonday", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_Every3MonthsOnTheSecondTuesday()
|
|
{
|
|
var startDate = new DateTime(2025, 10, 6);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 3,
|
|
WeekDay = DayOfWeek.Tuesday,
|
|
WeekInterval = 2, // WeekOfMonth.Second
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every3MonthsOnTheSecondTuesday", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_Every2MonthsOnTheFirstMonday()
|
|
{
|
|
var startDate = new DateTime(2025, 10, 6);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 2,
|
|
WeekDay = DayOfWeek.Monday,
|
|
WeekInterval = 1, // WeekOfMonth.First
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every2MonthsOnTheFirstMonday", recurrence, startDate);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public void Yearly_OnTheFirstOfFebruary()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementYearlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
Month = 2,
|
|
DayOfMonth = 1
|
|
};
|
|
|
|
this.VerifyDates("Yearly_OnTheFirstOfFebruary", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Yearly_OnThe29thOfFebruary()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementYearlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
Month = 2,
|
|
DayOfMonth = 29
|
|
};
|
|
|
|
this.VerifyDates("Yearly_OnThe29thOfFebruary", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Yearly_OnTheFirstMondayInMarch()
|
|
{
|
|
var startDate = new DateTime(2020, 9, 10);
|
|
|
|
var recurrence = new TaskManagementYearlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
Month = 3,
|
|
WeekDay = DayOfWeek.Monday,
|
|
WeekInterval = 1
|
|
};
|
|
|
|
this.VerifyDates("Yearly_OnTheFirstMondayInMarch", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_Every4MonthsOnThe31st_StartingJanuary31()
|
|
{
|
|
var startDate = new DateTime(2024, 1, 31);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 4,
|
|
DayOfMonth = 31,
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every4MonthsOnThe31st_StartingJanuary31", recurrence, startDate);
|
|
}
|
|
|
|
[Fact]
|
|
public void Monthly_Every3MonthsOnThe31st_StartingJanuary31()
|
|
{
|
|
var startDate = new DateTime(2024, 1, 31);
|
|
|
|
var recurrence = new TaskManagementMonthlyRecurrence
|
|
{
|
|
StartTime = startDate,
|
|
MonthInterval = 3,
|
|
DayOfMonth = 31,
|
|
};
|
|
|
|
this.VerifyDates("Monthly_Every3MonthsOnThe31st_StartingJanuary31", recurrence, startDate);
|
|
}
|
|
|
|
|
|
private void VerifyDates(string name, TaskManagementBaseRecurrence recurrence, DateTime start, int daysCount = 20)
|
|
{
|
|
var calculator = new TaskManagementTaskBL.RecurrenceCalculator(recurrence);
|
|
var dates = calculator.GetDates(start).Take(daysCount).ToList();
|
|
|
|
this.Verifier.Verify(name, dates);
|
|
|
|
Assert.DoesNotContain(dates, f => f.Date == start.Date); // Does NEVER contain the start date
|
|
}
|
|
}
|
|
}
|