Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for permission set + tests #19

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions model/Models/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ public SqlAssembly(string permissionSet, string name) {
PermissionSet = permissionSet;
Name = name;

if (PermissionSet == "SAFE_ACCESS")
PermissionSet = "SAFE";
}
if (PermissionSet == "SAFE_ACCESS")
PermissionSet = "SAFE";

if (PermissionSet == "UNSAFE_ACCESS")
PermissionSet = "UNSAFE";
}

public string ScriptCreate() {
var commands =
Expand Down
23 changes: 23 additions & 0 deletions test/AssemblyTester.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using NUnit.Framework;
using SchemaZen.Library.Models;

namespace SchemaZen.Tests {
[TestFixture]
public class AssemblyTester {

[Test]
[TestCase("SAFE_ACCESS", "SAFE")]
[TestCase("UNSAFE_ACCESS", "UNSAFE")]
[TestCase("EXTERNAL_ACCESS", "EXTERNAL_ACCESS")]
public void Assembly_WithPermissionSetCases(string permissionSet, string scriptedPermissionSet) {
var assembly = new SqlAssembly(permissionSet, "SchemazenAssembly");
assembly.Files.Add(new KeyValuePair<string, byte[]>("mydll", new byte[0]));

var expected = @"CREATE ASSEMBLY [SchemazenAssembly]
FROM 0x
WITH PERMISSION_SET = " + scriptedPermissionSet;
Assert.AreEqual(expected, assembly.ScriptCreate());
}
}
}
1 change: 0 additions & 1 deletion test/BatchSqlParserTester.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using NUnit.Framework;
using SchemaZen.Library;
using SchemaZen.Library.Models;

namespace SchemaZen.Tests {
[TestFixture]
Expand Down
1 change: 1 addition & 0 deletions test/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyTester.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserTester.cs" />
</ItemGroup>
Expand Down