using Centron.BusinessLogic; using Centron.BusinessLogic.Administration.Settings; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Administration.Updates; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.UpdateAvailableNotificationSettings { public class UpdateAvailableNotificationSettingsTest : EndToEndTest { public UpdateAvailableNotificationSettingsTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { this.CanReadSettings("InitialState"); this.CanChangeSettings("AllEmployeesWithNullList", UpdateAvailableNotificationKind.ShowToAllEmployees, null); this.CanChangeSettings("AdministratorsWithNewList", UpdateAvailableNotificationKind.ShowToAdministrators, new List()); this.CanChangeSettings("SelectedEmployeesWithList", UpdateAvailableNotificationKind.ShowToSelectedEmployees, new List { 1, 2, 3 }); this.ThrowsWhenNoEmployees(null); this.ThrowsWhenNoEmployees(new List()); } private void CanReadSettings(string name) { using (var session = new BLSession()) { var settings = session.GetBL().GetUpdateAvailableNotificationSettings(); this.Verifier.Verify(name, settings); } } private void CanChangeSettings(string name, UpdateAvailableNotificationKind kind, List employeeI3Ds) { UpdateAvailableNotificationSettingsDTO settings; using(var session = new BLSession()) { settings = session.GetBL().GetUpdateAvailableNotificationSettings(); } settings.NotificationKind = kind; settings.EmployeeI3Ds = employeeI3Ds; using (var session = new BLSession()) { session.GetBL().UpdateUpdateAvailableNotificationSettings(settings); } this.CanReadSettings(name); } private void ThrowsWhenNoEmployees(List employees) { var ex = Assert.Throws(() => this.CanChangeSettings("Throws", UpdateAvailableNotificationKind.ShowToSelectedEmployees, employees)); Assert.Equal(DefaultMessageCodes.BadRequest, ex.MessageCode); } } }