test(configmanager): expand unit test coverage to 451 tests
Add comprehensive tests for services (ConnectionTestService, RuntimeConfigValidation), ViewModels (PipelineEditor, dialogs, transformers), and Avalonia headless UI tests for views and forms.
This commit is contained in:
+484
-62
@@ -22,7 +22,7 @@ public class ConnectionStringsFormViewModelTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_InitializesFromModel()
|
||||
public void Constructor_InitializesFromModel()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
@@ -54,67 +54,67 @@ public class ConnectionStringsFormViewModelTests
|
||||
sut.Connections[0].Server.ShouldBe("server1");
|
||||
sut.Connections[1].Name.ShouldBe("Connection2");
|
||||
sut.Connections[1].Provider.ShouldBe(ConnectionProvider.Oracle);
|
||||
sut.Connections[1].Host.ShouldBe("oracle-host");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsAndParsesSqlServerConnectionStringFromSecureStore()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "LotFinder" }
|
||||
}
|
||||
};
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
_secureStoreManager.GetSecret("LotFinder")
|
||||
.Returns("Server=localhost,1434;Database=ScopingTool;User Id=scopingapp;Password=pass;TrustServerCertificate=true");
|
||||
|
||||
// Act
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Provider.ShouldBe(ConnectionProvider.SqlServer);
|
||||
sut.Connections[0].Server.ShouldBe("localhost,1434");
|
||||
sut.Connections[0].Database.ShouldBe("ScopingTool");
|
||||
sut.Connections[0].UserId.ShouldBe("scopingapp");
|
||||
sut.Connections[0].Password.ShouldBe("pass");
|
||||
sut.Connections[0].TrustServerCertificate.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsAndParsesOracleConnectionStringFromSecureStore()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "CMS" }
|
||||
}
|
||||
};
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
_secureStoreManager.GetSecret("CMS")
|
||||
.Returns("HOST=ha-iman;Service Name=imanprd;Fetch Array Size=1280000;Port=1522;User ID=app_teamcenter;Password=pass;");
|
||||
|
||||
// Act
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Provider.ShouldBe(ConnectionProvider.Oracle);
|
||||
sut.Connections[0].Host.ShouldBe("ha-iman");
|
||||
sut.Connections[0].ServiceName.ShouldBe("imanprd");
|
||||
sut.Connections[0].Port.ShouldBe(1522);
|
||||
sut.Connections[0].UserId.ShouldBe("app_teamcenter");
|
||||
sut.Connections[0].Password.ShouldBe("pass");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullModel()
|
||||
sut.Connections[1].Host.ShouldBe("oracle-host");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsAndParsesSqlServerConnectionStringFromSecureStore()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "LotFinder" }
|
||||
}
|
||||
};
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
_secureStoreManager.GetSecret("LotFinder")
|
||||
.Returns("Server=localhost,1434;Database=ScopingTool;User Id=scopingapp;Password=pass;TrustServerCertificate=true");
|
||||
|
||||
// Act
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Provider.ShouldBe(ConnectionProvider.SqlServer);
|
||||
sut.Connections[0].Server.ShouldBe("localhost,1434");
|
||||
sut.Connections[0].Database.ShouldBe("ScopingTool");
|
||||
sut.Connections[0].UserId.ShouldBe("scopingapp");
|
||||
sut.Connections[0].Password.ShouldBe("pass");
|
||||
sut.Connections[0].TrustServerCertificate.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsAndParsesOracleConnectionStringFromSecureStore()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "CMS" }
|
||||
}
|
||||
};
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
_secureStoreManager.GetSecret("CMS")
|
||||
.Returns("HOST=ha-iman;Service Name=imanprd;Fetch Array Size=1280000;Port=1522;User ID=app_teamcenter;Password=pass;");
|
||||
|
||||
// Act
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Provider.ShouldBe(ConnectionProvider.Oracle);
|
||||
sut.Connections[0].Host.ShouldBe("ha-iman");
|
||||
sut.Connections[0].ServiceName.ShouldBe("imanprd");
|
||||
sut.Connections[0].Port.ShouldBe(1522);
|
||||
sut.Connections[0].UserId.ShouldBe("app_teamcenter");
|
||||
sut.Connections[0].Password.ShouldBe("pass");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullModel()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() =>
|
||||
@@ -237,4 +237,426 @@ public class ConnectionStringsFormViewModelTests
|
||||
// Assert
|
||||
sut.ConnectionCount.ShouldBe(4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_InitializesConnectionsFromModel()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "TestConnection",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
Database = "TestDb",
|
||||
UserId = "sa",
|
||||
Password = "secret"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Name.ShouldBe("TestConnection");
|
||||
sut.Connections[0].Provider.ShouldBe(ConnectionProvider.SqlServer);
|
||||
sut.Connections[0].Server.ShouldBe("localhost");
|
||||
sut.Connections[0].Database.ShouldBe("TestDb");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddConnectionCommand_AddsNewConnection()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection();
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
var initialCount = sut.Connections.Count;
|
||||
|
||||
// Act
|
||||
sut.AddConnectionCommand.Execute(null);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(initialCount + 1);
|
||||
sut.Connections.Last().Name.ShouldBe("NewConnection");
|
||||
sut.Connections.Last().Provider.ShouldBe(ConnectionProvider.Generic);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteConnectionCommand_WhenConfirmed_RemovesConnection()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "ToDelete" }
|
||||
}
|
||||
};
|
||||
_dialogService.ShowConfirmationAsync(Arg.Any<string>(), Arg.Any<string>())
|
||||
.Returns(true);
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.DeleteConnectionCommand.Execute(null);
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(0);
|
||||
model.Entries.Count.ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteConnectionCommand_WhenCancelled_KeepsConnection()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "ToKeep" }
|
||||
}
|
||||
};
|
||||
_dialogService.ShowConfirmationAsync(Arg.Any<string>(), Arg.Any<string>())
|
||||
.Returns(false);
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.DeleteConnectionCommand.Execute(null);
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Name.ShouldBe("ToKeep");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ValidateConnectionCommand_WithEmptyConnectionString_ShowsError()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "EmptyConnection",
|
||||
Provider = ConnectionProvider.Generic,
|
||||
RawConnectionString = ""
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.ValidateConnectionCommand.Execute(null);
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert
|
||||
await _dialogService.Received().ShowMessageAsync(
|
||||
"Validation Failed",
|
||||
Arg.Is<string>(s => s.Contains("empty connection string")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ValidateConnectionCommand_WithValidConnectionString_ShowsSuccess()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "ValidConnection",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
Database = "TestDb"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.ValidateConnectionCommand.Execute(null);
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert
|
||||
await _dialogService.Received().ShowMessageAsync(
|
||||
"Validation Passed",
|
||||
Arg.Is<string>(s => s.Contains("valid connection string")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestConnectionCommand_WhenSuccessful_ShowsSuccessMessage()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "TestConn",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
Database = "TestDb"
|
||||
}
|
||||
}
|
||||
};
|
||||
_connectionTestService.TestConnectionAsync(Arg.Any<string>(), Arg.Any<ConnectionProvider>(), Arg.Any<CancellationToken>())
|
||||
.Returns(new ConnectionTestResult { Success = true, Duration = TimeSpan.FromMilliseconds(50) });
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.TestConnectionCommand.Execute(null);
|
||||
await Task.Delay(150);
|
||||
|
||||
// Assert
|
||||
await _dialogService.Received().ShowMessageAsync(
|
||||
"Connection Successful",
|
||||
Arg.Is<string>(s => s.Contains("Successfully connected")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestConnectionCommand_WhenFailed_ShowsErrorMessage()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "FailConn",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "badserver",
|
||||
Database = "TestDb"
|
||||
}
|
||||
}
|
||||
};
|
||||
_connectionTestService.TestConnectionAsync(Arg.Any<string>(), Arg.Any<ConnectionProvider>(), Arg.Any<CancellationToken>())
|
||||
.Returns(new ConnectionTestResult { Success = false, Message = "Connection refused" });
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.TestConnectionCommand.Execute(null);
|
||||
await Task.Delay(150);
|
||||
|
||||
// Assert
|
||||
await _dialogService.Received().ShowMessageAsync(
|
||||
"Connection Failed",
|
||||
Arg.Is<string>(s => s.Contains("Failed to connect") && s.Contains("Connection refused")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestConnectionCommand_SetsIsTesting_DuringExecution()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "TestConn",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
Database = "TestDb"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<ConnectionTestResult>();
|
||||
_connectionTestService.TestConnectionAsync(Arg.Any<string>(), Arg.Any<ConnectionProvider>(), Arg.Any<CancellationToken>())
|
||||
.Returns(taskCompletionSource.Task);
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act - Start the command
|
||||
sut.TestConnectionCommand.Execute(null);
|
||||
await Task.Delay(50);
|
||||
|
||||
// Assert - IsTesting should be true during execution
|
||||
sut.IsTesting.ShouldBeTrue();
|
||||
|
||||
// Complete the task
|
||||
taskCompletionSource.SetResult(new ConnectionTestResult { Success = true });
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert - IsTesting should be false after completion
|
||||
sut.IsTesting.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectedConnection_WhenChanged_RaisesHasSelectionPropertyChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "Conn1" }
|
||||
}
|
||||
};
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
var hasSelectionChangedRaised = false;
|
||||
sut.PropertyChanged += (s, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(ConnectionStringsFormViewModel.HasSelection))
|
||||
hasSelectionChangedRaised = true;
|
||||
};
|
||||
|
||||
// Act
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Assert
|
||||
hasSelectionChangedRaised.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnEntryChanged_SavesValueToSecureStore()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "TestConn",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
Database = "TestDb"
|
||||
}
|
||||
}
|
||||
};
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
|
||||
var onChangedCalled = false;
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => onChangedCalled = true, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act - Change a property on the selected connection
|
||||
sut.SelectedConnection.Database = "NewDatabase";
|
||||
|
||||
// Assert
|
||||
onChangedCalled.ShouldBeTrue();
|
||||
_secureStoreManager.Received().SetSecret("TestConn", Arg.Any<string>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteConnectionCommand_RemovesFromSecureStore()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry { Name = "ToDelete" }
|
||||
}
|
||||
};
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
_dialogService.ShowConfirmationAsync(Arg.Any<string>(), Arg.Any<string>())
|
||||
.Returns(true);
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.DeleteConnectionCommand.Execute(null);
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert
|
||||
_secureStoreManager.Received().RemoveSecret("ToDelete");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddConnectionCommand_CreatesSecureStoreEntry()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection();
|
||||
_secureStoreManager.IsStoreOpen.Returns(true);
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Act
|
||||
sut.AddConnectionCommand.Execute(null);
|
||||
|
||||
// Assert
|
||||
_secureStoreManager.Received().SetSecret("NewConnection", string.Empty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestConnectionCommand_WithEmptyConnectionString_ShowsMessage()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringsSection
|
||||
{
|
||||
Entries = new List<ConnectionStringEntry>
|
||||
{
|
||||
new ConnectionStringEntry
|
||||
{
|
||||
Name = "EmptyConn",
|
||||
Provider = ConnectionProvider.Generic,
|
||||
RawConnectionString = ""
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
sut.SelectedConnection = sut.Connections[0];
|
||||
|
||||
// Act
|
||||
sut.TestConnectionCommand.Execute(null);
|
||||
await Task.Delay(100);
|
||||
|
||||
// Assert
|
||||
await _dialogService.Received().ShowMessageAsync(
|
||||
"Test Connection",
|
||||
Arg.Is<string>(s => s.Contains("connection string is empty")));
|
||||
await _connectionTestService.DidNotReceive().TestConnectionAsync(
|
||||
Arg.Any<string>(),
|
||||
Arg.Any<ConnectionProvider>(),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AvailableProviders_ContainsAllProviders()
|
||||
{
|
||||
// Assert
|
||||
ConnectionStringsFormViewModel.AvailableProviders.Count.ShouldBe(
|
||||
Enum.GetValues<ConnectionProvider>().Length);
|
||||
ConnectionStringsFormViewModel.AvailableProviders.ShouldContain(ConnectionProvider.SqlServer);
|
||||
ConnectionStringsFormViewModel.AvailableProviders.ShouldContain(ConnectionProvider.Oracle);
|
||||
ConnectionStringsFormViewModel.AvailableProviders.ShouldContain(ConnectionProvider.Generic);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EncryptOptions_ContainsExpectedValues()
|
||||
{
|
||||
// Assert
|
||||
ConnectionStringsFormViewModel.EncryptOptions.Count.ShouldBe(3);
|
||||
ConnectionStringsFormViewModel.EncryptOptions.ShouldContain("True");
|
||||
ConnectionStringsFormViewModel.EncryptOptions.ShouldContain("False");
|
||||
ConnectionStringsFormViewModel.EncryptOptions.ShouldContain("Strict");
|
||||
}
|
||||
}
|
||||
|
||||
+630
@@ -0,0 +1,630 @@
|
||||
using JdeScoping.ConfigManager.Services;
|
||||
using JdeScoping.ConfigManager.ViewModels.Forms;
|
||||
using JdeScoping.ConfigManager.ViewModels.PipelineSteps;
|
||||
using JdeScoping.DataSync.Configuration;
|
||||
|
||||
namespace JdeScoping.ConfigManager.Tests.ViewModels.Forms;
|
||||
|
||||
public class PipelineEditorViewModelTests
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
|
||||
public PipelineEditorViewModelTests()
|
||||
{
|
||||
_dialogService = Substitute.For<IDialogService>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_InitializesPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var connections = new List<string> { "jde", "cms", "lotfinder" };
|
||||
|
||||
// Act
|
||||
var sut = new PipelineEditorViewModel("TestPipeline", model, connections, _dialogService, () => { });
|
||||
|
||||
// Assert
|
||||
sut.Name.ShouldBe("TestPipeline");
|
||||
sut.AvailableConnections.ShouldBe(connections);
|
||||
sut.PreScripts.ShouldNotBeNull();
|
||||
sut.Transformers.ShouldNotBeNull();
|
||||
sut.PostScripts.ShouldNotBeNull();
|
||||
sut.Source.ShouldNotBeNull();
|
||||
sut.Destination.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_BuildsSourceAndDestinationFromModel()
|
||||
{
|
||||
// Arrange
|
||||
var model = new EtlPipelineConfig
|
||||
{
|
||||
Source = new SourceElement { Connection = "jde", Query = "SELECT * FROM WO" },
|
||||
Destination = new DestinationElement { Table = "WorkOrder_Curr" }
|
||||
};
|
||||
var connections = new List<string> { "jde" };
|
||||
|
||||
// Act
|
||||
var sut = new PipelineEditorViewModel("TestPipeline", model, connections, _dialogService, () => { });
|
||||
|
||||
// Assert
|
||||
sut.Source.Connection.ShouldBe("jde");
|
||||
sut.Source.Query.ShouldBe("SELECT * FROM WO");
|
||||
sut.Destination.Table.ShouldBe("WorkOrder_Curr");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsEnabled_Setter_UpdatesModelAndInvokesOnChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
model.IsEnabled = false;
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.IsEnabled = true;
|
||||
|
||||
// Assert
|
||||
sut.IsEnabled.ShouldBeTrue();
|
||||
model.IsEnabled.ShouldBeTrue();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsManualOnly_Setter_UpdatesModelAndInvokesOnChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
model.IsManualOnly = false;
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.IsManualOnly = true;
|
||||
|
||||
// Assert
|
||||
sut.IsManualOnly.ShouldBeTrue();
|
||||
model.IsManualOnly.ShouldBeTrue();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MassSyncEnabled_ToggleOn_SetsDefaultInterval()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
model.MassSyncIntervalMinutes = null;
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.MassSyncEnabled = true;
|
||||
|
||||
// Assert
|
||||
sut.MassSyncEnabled.ShouldBeTrue();
|
||||
sut.MassSyncIntervalMinutes.ShouldBe(10080); // 1 week default
|
||||
model.MassSyncIntervalMinutes.ShouldBe(10080);
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MassSyncEnabled_ToggleOff_ClearsInterval()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
model.MassSyncIntervalMinutes = 10080;
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.MassSyncEnabled = false;
|
||||
|
||||
// Assert
|
||||
sut.MassSyncEnabled.ShouldBeFalse();
|
||||
model.MassSyncIntervalMinutes.ShouldBeNull();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DailySyncEnabled_ToggleOn_SetsDefaultInterval()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
model.DailySyncIntervalMinutes = null;
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.DailySyncEnabled = true;
|
||||
|
||||
// Assert
|
||||
sut.DailySyncEnabled.ShouldBeTrue();
|
||||
sut.DailySyncIntervalMinutes.ShouldBe(1440); // 1 day default
|
||||
model.DailySyncIntervalMinutes.ShouldBe(1440);
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HourlySyncEnabled_ToggleOn_SetsDefaultInterval()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
model.HourlySyncIntervalMinutes = null;
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.HourlySyncEnabled = true;
|
||||
|
||||
// Assert
|
||||
sut.HourlySyncEnabled.ShouldBeTrue();
|
||||
sut.HourlySyncIntervalMinutes.ShouldBe(60); // 1 hour default
|
||||
model.HourlySyncIntervalMinutes.ShouldBe(60);
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectedStep_Setter_DeselectsPreviousAndSelectsNew()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
var source = sut.Source;
|
||||
var destination = sut.Destination;
|
||||
|
||||
// Act - Select source
|
||||
sut.SelectedStep = source;
|
||||
|
||||
// Assert
|
||||
source.IsSelected.ShouldBeTrue();
|
||||
sut.SelectedStep.ShouldBe(source);
|
||||
|
||||
// Act - Select destination (should deselect source)
|
||||
sut.SelectedStep = destination;
|
||||
|
||||
// Assert
|
||||
source.IsSelected.ShouldBeFalse();
|
||||
destination.IsSelected.ShouldBeTrue();
|
||||
sut.SelectedStep.ShouldBe(destination);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDeleteSelectedStep_ReturnsFalse_ForSourceStep()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Act
|
||||
sut.SelectedStep = sut.Source;
|
||||
|
||||
// Assert
|
||||
sut.CanDeleteSelectedStep.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDeleteSelectedStep_ReturnsFalse_ForDestinationStep()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Act
|
||||
sut.SelectedStep = sut.Destination;
|
||||
|
||||
// Assert
|
||||
sut.CanDeleteSelectedStep.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDeleteSelectedStep_ReturnsTrue_ForTransformerStep()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add a transformer
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
var transformer = sut.Transformers[0];
|
||||
|
||||
// Act
|
||||
sut.SelectedStep = transformer;
|
||||
|
||||
// Assert
|
||||
sut.CanDeleteSelectedStep.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDeleteSelectedStep_ReturnsTrue_ForPreScriptStep()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add a pre-script
|
||||
sut.AddPreScriptCommand.Execute(null);
|
||||
var preScript = sut.PreScripts[0];
|
||||
|
||||
// Act
|
||||
sut.SelectedStep = preScript;
|
||||
|
||||
// Assert
|
||||
sut.CanDeleteSelectedStep.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDeleteSelectedStep_ReturnsTrue_ForPostScriptStep()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add a post-script
|
||||
sut.AddPostScriptCommand.Execute(null);
|
||||
var postScript = sut.PostScripts[0];
|
||||
|
||||
// Act
|
||||
sut.SelectedStep = postScript;
|
||||
|
||||
// Assert
|
||||
sut.CanDeleteSelectedStep.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddPreScriptCommand_AddsPreScriptAndSelectsIt()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.AddPreScriptCommand.Execute(null);
|
||||
|
||||
// Assert
|
||||
sut.PreScripts.Count.ShouldBe(1);
|
||||
sut.SelectedStep.ShouldBe(sut.PreScripts[0]);
|
||||
sut.PreScripts[0].IsSelected.ShouldBeTrue();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddTransformerCommand_AddsTransformerAndSelectsIt()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
|
||||
// Assert
|
||||
sut.Transformers.Count.ShouldBe(1);
|
||||
sut.SelectedStep.ShouldBe(sut.Transformers[0]);
|
||||
sut.Transformers[0].IsSelected.ShouldBeTrue();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddPostScriptCommand_AddsPostScriptAndSelectsIt()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.AddPostScriptCommand.Execute(null);
|
||||
|
||||
// Assert
|
||||
sut.PostScripts.Count.ShouldBe(1);
|
||||
sut.SelectedStep.ShouldBe(sut.PostScripts[0]);
|
||||
sut.PostScripts[0].IsSelected.ShouldBeTrue();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveStepCommand_RemovesSelectedStep()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var changedInvoked = false;
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => changedInvoked = true);
|
||||
|
||||
// Add a transformer first
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
var transformer = sut.Transformers[0];
|
||||
changedInvoked = false;
|
||||
|
||||
// Act
|
||||
sut.RemoveStepCommand.Execute(transformer);
|
||||
|
||||
// Assert
|
||||
sut.Transformers.Count.ShouldBe(0);
|
||||
sut.SelectedStep.ShouldBeNull();
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveStepUpCommand_MovesStepUpInCollection()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add two transformers
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
var firstTransformer = sut.Transformers[0];
|
||||
var secondTransformer = sut.Transformers[1];
|
||||
|
||||
// Act - Move second up
|
||||
sut.MoveStepUpCommand.Execute(secondTransformer);
|
||||
|
||||
// Assert
|
||||
sut.Transformers[0].ShouldBe(secondTransformer);
|
||||
sut.Transformers[1].ShouldBe(firstTransformer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveStepDownCommand_MovesStepDownInCollection()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add two transformers
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
var firstTransformer = sut.Transformers[0];
|
||||
var secondTransformer = sut.Transformers[1];
|
||||
|
||||
// Act - Move first down
|
||||
sut.MoveStepDownCommand.Execute(firstTransformer);
|
||||
|
||||
// Assert
|
||||
sut.Transformers[0].ShouldBe(secondTransformer);
|
||||
sut.Transformers[1].ShouldBe(firstTransformer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveStepUpCommand_DoesNotMove_WhenAtTop()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add two transformers
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
var firstTransformer = sut.Transformers[0];
|
||||
var secondTransformer = sut.Transformers[1];
|
||||
|
||||
// Act - Try to move first up (should do nothing)
|
||||
sut.MoveStepUpCommand.Execute(firstTransformer);
|
||||
|
||||
// Assert
|
||||
sut.Transformers[0].ShouldBe(firstTransformer);
|
||||
sut.Transformers[1].ShouldBe(secondTransformer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveStepDownCommand_DoesNotMove_WhenAtBottom()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Add two transformers
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
sut.AddTransformerCommand.Execute(null);
|
||||
var firstTransformer = sut.Transformers[0];
|
||||
var secondTransformer = sut.Transformers[1];
|
||||
|
||||
// Act - Try to move second down (should do nothing)
|
||||
sut.MoveStepDownCommand.Execute(secondTransformer);
|
||||
|
||||
// Assert
|
||||
sut.Transformers[0].ShouldBe(firstTransformer);
|
||||
sut.Transformers[1].ShouldBe(secondTransformer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullName()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() =>
|
||||
new PipelineEditorViewModel(null!, model, [], _dialogService, () => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullModel()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() =>
|
||||
new PipelineEditorViewModel("Test", null!, [], _dialogService, () => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullDialogService()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() =>
|
||||
new PipelineEditorViewModel("Test", model, [], null!, () => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullOnChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() =>
|
||||
new PipelineEditorViewModel("Test", model, [], _dialogService, null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsExistingTransformers()
|
||||
{
|
||||
// Arrange
|
||||
var model = new EtlPipelineConfig
|
||||
{
|
||||
Source = new SourceElement { Connection = "jde", Query = "SELECT * FROM WO" },
|
||||
Destination = new DestinationElement { Table = "WorkOrder" },
|
||||
Transforms =
|
||||
[
|
||||
new TransformElement { TransformType = "ColumnDrop" },
|
||||
new TransformElement { TransformType = "ColumnRename" }
|
||||
]
|
||||
};
|
||||
|
||||
// Act
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Assert
|
||||
sut.Transformers.Count.ShouldBe(2);
|
||||
sut.Transformers[0].ShouldBeOfType<ColumnDropTransformerViewModel>();
|
||||
sut.Transformers[1].ShouldBeOfType<ColumnRenameTransformerViewModel>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsExistingPreScripts()
|
||||
{
|
||||
// Arrange
|
||||
var model = new EtlPipelineConfig
|
||||
{
|
||||
Source = new SourceElement { Connection = "jde", Query = "SELECT * FROM WO" },
|
||||
Destination = new DestinationElement { Table = "WorkOrder" },
|
||||
PreScripts = [new ScriptElement { Connection = "lotfinder", Script = "TRUNCATE TABLE Test" }]
|
||||
};
|
||||
|
||||
// Act
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Assert
|
||||
sut.PreScripts.Count.ShouldBe(1);
|
||||
sut.PreScripts[0].Script.ShouldBe("TRUNCATE TABLE Test");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_LoadsExistingPostScripts()
|
||||
{
|
||||
// Arrange
|
||||
var model = new EtlPipelineConfig
|
||||
{
|
||||
Source = new SourceElement { Connection = "jde", Query = "SELECT * FROM WO" },
|
||||
Destination = new DestinationElement { Table = "WorkOrder" },
|
||||
PostScripts = [new ScriptElement { Connection = "lotfinder", Script = "UPDATE Stats SET LastRun = GETDATE()" }]
|
||||
};
|
||||
|
||||
// Act
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Assert
|
||||
sut.PostScripts.Count.ShouldBe(1);
|
||||
sut.PostScripts[0].Script.ShouldBe("UPDATE Stats SET LastRun = GETDATE()");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllSteps_ReturnsAllStepsInOrder()
|
||||
{
|
||||
// Arrange
|
||||
var model = new EtlPipelineConfig
|
||||
{
|
||||
Source = new SourceElement { Connection = "jde", Query = "SELECT * FROM WO" },
|
||||
Destination = new DestinationElement { Table = "WorkOrder" },
|
||||
PreScripts = [new ScriptElement { Script = "pre" }],
|
||||
Transforms = [new TransformElement { TransformType = "ColumnDrop" }],
|
||||
PostScripts = [new ScriptElement { Script = "post" }]
|
||||
};
|
||||
|
||||
// Act
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
var allSteps = sut.AllSteps.ToList();
|
||||
|
||||
// Assert
|
||||
allSteps.Count.ShouldBe(5);
|
||||
allSteps[0].ShouldBeOfType<PreScriptStepViewModel>();
|
||||
allSteps[1].ShouldBeOfType<SourceStepViewModel>();
|
||||
allSteps[2].ShouldBeOfType<ColumnDropTransformerViewModel>();
|
||||
allSteps[3].ShouldBeOfType<DestinationStepViewModel>();
|
||||
allSteps[4].ShouldBeOfType<PostScriptStepViewModel>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectedStepEditor_UpdatesWhenSelectedStepChanges()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Act
|
||||
sut.SelectedStep = sut.Source;
|
||||
|
||||
// Assert
|
||||
sut.SelectedStepEditor.ShouldBe(sut.Source);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddTransformerOfType_AddsSpecificTransformerType()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Act
|
||||
sut.AddTransformerOfType("JdeDate");
|
||||
|
||||
// Assert
|
||||
sut.Transformers.Count.ShouldBe(1);
|
||||
sut.Transformers[0].ShouldBeOfType<JdeDateTransformerViewModel>();
|
||||
sut.SelectedStep.ShouldBe(sut.Transformers[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectedTransformerType_SetterAndGetter_Work()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Act
|
||||
sut.SelectedTransformerType = "ColumnRename";
|
||||
|
||||
// Assert
|
||||
sut.SelectedTransformerType.ShouldBe("ColumnRename");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AvailableTransformerTypes_ReturnsExpectedTypes()
|
||||
{
|
||||
// Arrange
|
||||
var model = CreateDefaultModel();
|
||||
var sut = new PipelineEditorViewModel("Test", model, [], _dialogService, () => { });
|
||||
|
||||
// Assert
|
||||
sut.AvailableTransformerTypes.ShouldContain("ColumnDrop");
|
||||
sut.AvailableTransformerTypes.ShouldContain("ColumnRename");
|
||||
sut.AvailableTransformerTypes.ShouldContain("JdeDate");
|
||||
sut.AvailableTransformerTypes.ShouldContain("Regex");
|
||||
}
|
||||
|
||||
private static EtlPipelineConfig CreateDefaultModel()
|
||||
{
|
||||
return new EtlPipelineConfig
|
||||
{
|
||||
Source = new SourceElement { Connection = string.Empty, Query = string.Empty },
|
||||
Destination = new DestinationElement { Table = string.Empty }
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user