Inheritance: IEsbManagementEndpoint
 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.");

        }
        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-------------------------
            Assert.IsTrue(File.Exists("secure.config"));
            File.Delete("secure.config");

            var msg = ToMsg(execute);

            StringAssert.Contains(msg.Message.ToString(), "Success");
        }
        public void SettingsWrite_CreateServiceEntry_ReturnsDynamicService()
        {
            var esb = new SettingsWrite();
            var result = esb.CreateServiceEntry();
            Assert.AreEqual(esb.HandlesType(), result.Name);
            Assert.AreEqual("<DataList><Settings ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>", result.DataListSpecification.ToString());
            Assert.AreEqual(1, result.Actions.Count);

            var serviceAction = result.Actions[0];
            Assert.AreEqual(esb.HandlesType(), serviceAction.Name);
            Assert.AreEqual(enActionType.InvokeManagementDynamicService, serviceAction.ActionType);
            Assert.AreEqual(esb.HandlesType(), serviceAction.SourceMethod);
        }
 public void SettingsWrite_HandlesType_ReturnsSettingsWriteService()
 {
     var esb = new SettingsWrite();
     var result = esb.HandlesType();
     Assert.AreEqual("SettingsWriteService", result);
 }