using System; using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.Notifications; using Centron.BusinessLogic.WebServices.Notifications; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Notifications; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.CentronNotification { public class CentronNotificationTest : EndToEndTest { public CentronNotificationTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { this.CreateNotifications(); this.DeleteCentronNotification(); this.LoadCentronNotifications(); } private void CreateNotifications() { using (var session = new BLSession()) { var notificationError = new Data.Entities.Notifications.CentronNotification { LogKind = LogKind.Error, Text = "Developer: We have a problem", CreatedDate = DateTime.Now, ShortSign = "Dienst", ObjectKind = 123, ObjectI3D = null }; var notificationSucces = new Data.Entities.Notifications.CentronNotification() { LogKind = LogKind.Successful, Text = "Manager: There are no such things as problems, only opportunities", CreatedDate = DateTime.Now, ShortSign = "Dienst", ObjectKind = 321, ObjectI3D = 42 }; var notifificationPartlyError = new Data.Entities.Notifications.CentronNotification() { LogKind = LogKind.PartlyError, Text = "Developer: Well then, we have a DDoS opportunity", CreatedDate = DateTime.Now, ShortSign = "Dienst" }; var notificationForDelete = new Data.Entities.Notifications.CentronNotification() { LogKind = LogKind.Successful, Text = "If you find me in the final text file, something went wrong", CreatedDate = DateTime.Now.AddDays(-15), ShortSign = "Waldo" }; session.GetBL().SaveCentronNotification(notificationError); session.GetBL().SaveCentronNotification(notificationSucces); session.GetBL().SaveCentronNotification(notifificationPartlyError); session.GetBL().SaveCentronNotification(notificationForDelete); } } private void DeleteCentronNotification() { var filter = new CentronNotificationsFilter() { DateUntil = DateTime.Now.AddDays(-14) }; using (var session = new BLSession()) { session.GetBL().DeleteCentronNotifications(filter); } } private void LoadCentronNotifications() { using (var session = new BLSession()) { var centronNotifiactions = session.GetBL().GetCentronNotificationsByFilter(new CentronNotificationsFilter()); this.Verifier.Verify("CentronNotification", centronNotifiactions.Data); } } } }