public void CanCreateUpdateDeleteVariable()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                using (AutomationTestBase _testFixture = new AutomationTestBase())
                {
                    var variableName = TestUtilities.GenerateName("variable");
                    var value        = 10;

                    Variable variable = _testFixture.CreateVariable(variableName, value);
                    Assert.NotNull(variable);

                    variable = _testFixture.GetVariable(variable.Name);
                    Assert.NotNull(variable);
                    Assert.Equal(value, Convert.ToInt32(JsonConvert.DeserializeObject <object>(variable.Properties.Value)));

                    value = 20;
                    variable.Properties.Value       = JsonConvert.SerializeObject(value);
                    variable.Properties.Description = "int typed variable";
                    _testFixture.UpdateVariable(variable);
                    var variables = _testFixture.GetVariables();
                    Assert.Equal(1, variables.Count);
                    var updatedVariable = variables[0];
                    Assert.Equal(value, Convert.ToInt32(JsonConvert.DeserializeObject <object>(updatedVariable.Properties.Value)));
                    Assert.Equal(variable.Properties.Description, updatedVariable.Properties.Description);

                    _testFixture.DeleteVariable(variable.Name);

                    Assert.Throws <CloudException>(() =>
                    {
                        variable = _testFixture.GetVariable(variable.Name);
                    });
                }
            }
        }
예제 #2
0
        public void CanCreateUpdateDeleteVariable()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                using (AutomationTestBase _testFixture = new AutomationTestBase())
                {
                    var variableName = TestUtilities.GenerateName("variable");
                    var value = 10;

                    Variable variable = _testFixture.CreateVariable(variableName, value);
                    Assert.NotNull(variable);

                    variable = _testFixture.GetVariable(variable.Name);
                    Assert.NotNull(variable);
                    Assert.Equal(value, Convert.ToInt32(JsonConvert.DeserializeObject<object>(variable.Properties.Value)));

                    value = 20;
                    variable.Properties.Value = JsonConvert.SerializeObject(value);
                    variable.Properties.Description = "int typed variable";
                    _testFixture.UpdateVariable(variable);
                    var variables = _testFixture.GetVariables();
                    Assert.Equal(1, variables.Count);
                    var updatedVariable = variables[0];
                    Assert.Equal(value, Convert.ToInt32(JsonConvert.DeserializeObject<object>(updatedVariable.Properties.Value)));
                    Assert.Equal(variable.Properties.Description, updatedVariable.Properties.Description);

                    _testFixture.DeleteVariable(variable.Name);

                    Assert.Throws<CloudException>(() =>
                    {
                        variable = _testFixture.GetVariable(variable.Name);
                    });
                }
            }
        }