Skip to content

Commit

Permalink
Fix for permission set + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcio-santos-zocdoc committed Jun 1, 2016
1 parent ec8c404 commit ff5ecbe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
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

0 comments on commit ff5ecbe

Please sign in to comment.