namespace Centron.Tests.BL.MyDay; using Centron.DAO.Mappings.MyDay; using Centron.Interfaces.BL; using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate.Tool.hbm2ddl; using System.Collections.Generic; using Centron.BusinessLogic.MyDay; using Centron.DAO; using Centron.Data.Entities.MyDay; using Centron.Data.WebServices.Tapi; using Centron.Interfaces; using JetBrains.Annotations; using NHibernate; using Xunit; [TestSubject(typeof(MyDayBL))] public class MyDayBLTest { [Fact] public void GetEmployeeSelectionWorksAsExpected() { var session = CreateSession(); var myDayEmployeeSelection = new MyDayEmployeeSelection(); myDayEmployeeSelection.EmployeeI3D = 10; myDayEmployeeSelection.AppUserI3D = 1; myDayEmployeeSelection.DepartementI3D = 2; var expectedResult = Result>.AsSuccess(new List { myDayEmployeeSelection }); session.Save(myDayEmployeeSelection); session.Flush(); var daoSession = new DAOSession(session); var myDayBL = new MyDayBL(daoSession); var appUserI3D = 1; var result = myDayBL.GetEmployeeSelection(appUserI3D); Assert.Equivalent(expectedResult, result); } [Fact] public void CreateGroupCallCaptionListsOtherParticipantsAndOrganizer() { var phoneCalls = new List { new() { CreatedBy = 1, CreatorName = "Organizer", CreatorNumber = "organizer@example.com", OwnerKind = CentronObjectKindNumeric.EmployeeClass, OwnerI3D = 2, CallerName = "Anna", CallerNumber = "anna@example.com" }, new() { CreatedBy = 1, CreatorName = "Organizer", CreatorNumber = "organizer@example.com", OwnerKind = CentronObjectKindNumeric.EmployeeClass, OwnerI3D = 3, CallerName = "Bob", CallerNumber = "bob@example.com" } }; var caption = MyDayBL.CreateGroupCallCaption(phoneCalls, 2); Assert.Equal("Microsoft Teams-Gruppengespräch mit Bob (bob@example.com), Organizer (organizer@example.com).", caption); } [Fact] public void GetPhoneCallPeriodUsesFullGroupCallDuration() { var startTime = new DateTime(2026, 7, 30, 13, 23, 32); var phoneCalls = new List { new() { StartTime = startTime.AddMinutes(2), EndTime = startTime.AddSeconds(241) }, new() { StartTime = startTime, EndTime = startTime.AddSeconds(916) } }; var period = MyDayBL.GetPhoneCallPeriod(phoneCalls); Assert.Equal(startTime, period.StartTime); Assert.Equal(startTime.AddSeconds(916), period.EndTime); } public ISession CreateSession() { var fluentConfiguration = Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory) .Mappings(m => m.FluentMappings.Add()); ISessionFactory sessionFactory = fluentConfiguration.BuildSessionFactory(); ISession session = sessionFactory.OpenSession(); new SchemaExport(fluentConfiguration.BuildConfiguration()).Execute(true, true, false, session.Connection, Console.Out); return session; } }