public void SettingsWrite_Execute_SettingsWriteValuePassedValidJSON_ShouldDoSecurityWrite() { //------------Setup for test-------------------------- var permission = new WindowsGroupPermission { Administrator = true, IsServer = true, WindowsGroup = Environment.UserName }; var windowsGroupPermissions = new List <WindowsGroupPermission> { permission }; var settings = new Settings { Security = new SecuritySettingsTO(windowsGroupPermissions) }; var serializeObject = JsonConvert.SerializeObject(settings); var settingsWrite = new SettingsWrite(); //------------Execute Test--------------------------- StringBuilder execute = settingsWrite.Execute(new Dictionary <string, StringBuilder> { { "Settings", new StringBuilder(serializeObject) } }, null); //------------Assert Results------------------------- var serverSecuritySettingsFile = EnvironmentVariables.ServerSecuritySettingsFile; Assert.IsTrue(File.Exists(serverSecuritySettingsFile)); File.Delete(serverSecuritySettingsFile); var msg = ToMsg(execute); StringAssert.Contains(msg.Message.ToString(), "Success"); }
public void SettingsWrite_Execute_NoValuesPassed_ExceptionThrown() { //------------Setup for test-------------------------- var settingsWrite = new SettingsWrite(); //------------Execute Test--------------------------- settingsWrite.Execute(null, null); //------------Assert Results------------------------- }
public void SettingsWrite_Execute_NoSettingsValuePassed_ExceptionThrown() { //------------Setup for test-------------------------- var settingsWrite = new SettingsWrite(); //------------Execute Test--------------------------- settingsWrite.Execute(new Dictionary <string, StringBuilder> { { "NoSettings", new StringBuilder("Something") } }, null); //------------Assert Results------------------------- }
public void SettingsWrite_Execute_SettingsValuePassedNotValidJSON_ExceptionThrown() { //------------Setup for test-------------------------- var settingsWrite = new SettingsWrite(); //------------Execute Test--------------------------- var execute = settingsWrite.Execute(new Dictionary <string, StringBuilder> { { "Settings", new StringBuilder("Something") } }, null); //------------Assert Results------------------------- StringAssert.Contains(execute.ToString(), "Error writing settings."); }