using Centron.BusinessLogic; using Centron.BusinessLogic.WebServices.Administration.FileManagement; using Centron.Data.WebServices.Administration.FileManagement; using Centron.Tests.EndToEnd.Infrastructure; using System; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Directories { public class DirectoriesTests : EndToEndTest { private int _referenceDirectoryI3D => 65; public DirectoriesTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { // need to be ignored so we don't get an actual version from the assembly which is always different this.Verifier.Settings.IgnoreProperty(f => f.ChangedVersion); this.Verifier.Settings.IgnoreProperty(f => f.CreatedVersion); } public override void Execute() { // since these are new values they would only ever be null this.Sql("UPDATE Directorys SET ChangedBy = 22, ChangedDate = '2021-01-01', CreatedVersion = '2.3.4.5', CreatedBy = 22, CreatedDate = '2020-01-01', ChangedVersion = '2.3.4.5' "); this.UserDirectoryRights(); this.LoadRootDirectory(); this.LoadDirectory(); this.RenameDirectory(); this.DeleteDirectory(); } private void UserDirectoryRights() { using (var session = new BLSession()) { var settings = session.GetBL().GetUserDirectorySettings(this.GetLoggedInUser()); this.Verifier.Verify("UserDirectorySettings", settings); } } private void LoadRootDirectory() { using (var session = new BLSession()) { var root = session.GetBL().GetRootDirectory(this.GetLoggedInUser()); this.Verifier.Verify("RootDirectory", root); } } private void LoadDirectory() { var directory = this.LoadReferenceDirectory(); this.Verifier.Verify("ReferenceDirectory", directory); using (var session = new BLSession()) { var subDirectories = session.GetBL().GetSubDirectories(this.GetLoggedInUser(), this._referenceDirectoryI3D); this.Verifier.Verify("ReferenceSubDirectories", subDirectories); } } private void RenameDirectory() { using (var session = new BLSession()) { session.GetBL().UpdateDirectoryName(this.GetLoggedInUser(), this._referenceDirectoryI3D, "newName"); } var directory = this.LoadReferenceDirectory(); this.Verifier.Verify("RenamedReferenceDirectory", directory?.Name); } private void DeleteDirectory() { using (var session = new BLSession()) { session.GetBL().DeleteDirectory(this.GetLoggedInUser(), this._referenceDirectoryI3D); } var directory = this.LoadReferenceDirectory(); Assert.Null(directory); } private DirectoryDTO LoadReferenceDirectory() { using var session = new BLSession(); return session.GetBL().GetDirectory(this.GetLoggedInUser(), this._referenceDirectoryI3D)?.Data; } } }