Resolve all 46 low-severity architecture review findings
This commit is contained in:
@@ -19,6 +19,21 @@ public class SharedScriptServiceTests
|
||||
_service = new SharedScriptService(_repoMock.Object, _auditMock.Object);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("return System.IO.File.ReadAllText(\"x\");")]
|
||||
[InlineData("return noSuchVariable;")]
|
||||
public async Task CreateAndUpdate_RejectInvalidCodeBeforeSaving(string code)
|
||||
{
|
||||
var existing = new SharedScript("Existing", "return 1;");
|
||||
_repoMock.Setup(r => r.GetSharedScriptByIdAsync(1, It.IsAny<CancellationToken>())).ReturnsAsync(existing);
|
||||
var create = await _service.CreateSharedScriptAsync("New", code, null, null, "admin");
|
||||
var update = await _service.UpdateSharedScriptAsync(1, code, null, null, "admin");
|
||||
Assert.True(create.IsFailure);
|
||||
Assert.True(update.IsFailure);
|
||||
Assert.Equal("return 1;", existing.Code);
|
||||
_repoMock.Verify(r => r.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Never);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_Success()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user