示例#1
0
        public void Should_return_null_when_property_name_is_null()
        {
            // Given
            var drop = new DynamicDrop(new object());

            // When
            var result = drop.BeforeMethod(null);

            // Then
            result.ShouldBeNull();
        }
示例#2
0
        public void Should_return_null_when_model_is_null()
        {
            // Given
            var drop = new DynamicDrop(null);

            // When
            var result = drop.BeforeMethod(string.Empty);

            // Then
            result.ShouldBeNull();
        }
示例#3
0
        public void Should_return_model_is_null_message_when_model_is_null()
        {
            // Given
            var drop = new DynamicDrop(null);

            // When
            var result = drop.BeforeMethod(string.Empty);

            // Then
            result.ShouldEqual("[Model is null]");
        }
示例#4
0
        public void Should_return_null_when_model_is_null()
        {
            // Given
            var drop = new DynamicDrop(null);

            // When
            var result = drop.BeforeMethod(string.Empty);

            // Then
            result.ShouldBeNull();
        }
示例#5
0
        public void Should_return_invalid_model_property_name_message_when_property_name_is_null()
        {
            // Given
            var drop = new DynamicDrop(new object());

            // When
            var result = drop.BeforeMethod(null);

            // Then
            result.ShouldEqual("[Invalid model property name]");
        }
示例#6
0
        public void Should_return_model_is_null_message_when_model_is_null()
        {
            // Given
            var drop = new DynamicDrop(null);

            // When
            var result = drop.BeforeMethod(string.Empty);

            // Then
            result.ShouldEqual("[Model is null]");
        }
示例#7
0
        public void Should_return_null_when_property_name_is_null()
        {
            // Given
            var drop = new DynamicDrop(new object());

            // When
            var result = drop.BeforeMethod(null);

            // Then
            result.ShouldBeNull();
        }
示例#8
0
        public void Should_return_invalid_model_property_name_message_when_property_name_is_null()
        {
            // Given
            var drop = new DynamicDrop(new object());

            // When
            var result = drop.BeforeMethod(null);

            // Then
            result.ShouldEqual("[Invalid model property name]");
        }
示例#9
0
        public void Should_return_message_about_property_not_being_found_when_called_with_invalid_property_name_and_model_is_object()
        {
            // Given
            var model = new FakeModel { Name = "Nancy" };
            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("age");

            // Then
            result.ShouldEqual("[Can't find :age in the model]");
        }
示例#10
0
        public void Should_return_message_about_property_not_being_found_when_called_with_invalid_property_name_and_model_is_object()
        {
            // Given
            var model = new FakeModel {
                Name = "Nancy"
            };
            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("age");

            // Then
            result.ShouldEqual("[Can't find :age in the model]");
        }
示例#11
0
        public void Should_return_null_when_called_with_invalid_property_name_and_model_is_expandoobject()
        {
            // Given
            dynamic model = new ExpandoObject();
            model.Name = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("age");

            // Then
            result.ShouldBeNull();
        }
示例#12
0
        public void Should_return_null_when_called_with_invalid_property_name_and_model_is_object()
        {
            // Given
            var model = new FakeModel {
                Name = "Nancy"
            };
            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("age");

            // Then
            result.ShouldBeNull();
        }
示例#13
0
        public void Should_return_model_value_when_property_name_is_valid_and_model_is_object()
        {
            // Given
            var model = new FakeModel {
                Name = "Nancy"
            };
            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldEqual("Nancy");
        }
示例#14
0
        public void Should_return_model_value_when_property_name_is_valid_and_model_is_expandoobject()
        {
            // Given
            dynamic model = new ExpandoObject();
            model.Name = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldEqual("Nancy");
        }
示例#15
0
        public void Should_return_model_value_when_property_name_is_wrong_case_and_model_is_expandoobject()
        {
            // Given
            dynamic model = new ExpandoObject();

            model.Name = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("name");

            // Then
            result.ShouldEqual("Nancy");
        }
示例#16
0
        public void Should_unwrap_dynamicdictionaryvalue_when_model_is_dynamicdictionary()
        {
            // Given
            var model = new DynamicDictionary();

            model["Name"] = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldBeOfType <string>();
        }
示例#17
0
        public void Should_return_model_value_when_property_name_is_valid_and_model_is_dynamicdictionary()
        {
            // Given
            var model = new DynamicDictionary();

            model["Name"] = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldEqual("Nancy");
        }
示例#18
0
        public void Should_return_null_when_called_with_invalid_property_name_and_model_is_dynamicdictionary()
        {
            // Given
            var model = new DynamicDictionary();

            model["Name"] = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("age");

            // Then
            result.ShouldBeNull();
        }
示例#19
0
        public virtual void RegisterTypes()
        {
            // .NET types
            Template.RegisterSafeType(typeof(Guid), member => member.ToString());

            Template.RegisterSafeType(typeof(Dictionary <string, string>), member => member.ToString());
            Template.RegisterSafeType(typeof(Dictionary <string, object>), member => member.ToString());
            Template.RegisterSafeType(typeof(IDictionary <string, string>), member => member.ToString());
            Template.RegisterSafeType(typeof(IDictionary <string, object>), member => member.ToString());

            /*
             * Template.RegisterSafeType(typeof(Dictionary<string, string>), new[] { "Keys", "Values", "Count" });
             * Template.RegisterSafeType(typeof(Dictionary<string, object>), new[] { "Keys", "Values", "Count" });
             * Template.RegisterSafeType(typeof(IDictionary<string, string>), new[] { "Keys", "Values", "Count" });
             * Template.RegisterSafeType(typeof(IDictionary<string, object>), new[] { "Keys", "Values", "Count" });
             */
            // Template.RegisterSafeType(typeof(KeyValuePair<string, string>), new[] { "Key", "Value" });
            Template.RegisterSafeType(typeof(KeyValuePair <string, string>), member => member.ToString());
            // Template.RegisterSafeType(typeof(KeyValuePair<string, object>), new[] { "Key", "Value", "Get_Key", "Get_Value" });
            // Template.RegisterSafeType(typeof(KeyValuePair<string, object>), new[] { "Key", "Value" });
            Template.RegisterSafeType(typeof(KeyValuePair <string, object>), member => member.ToString());
            // enumerations
            Template.RegisterSafeType(typeof(TestResultOrigins), member => member.ToString());
            Template.RegisterSafeType(typeof(TestRunStatuses), member => member.ToString());
            Template.RegisterSafeType(typeof(TestRunStartTypes), member => member.ToString());
            Template.RegisterSafeType(typeof(TestTaskStatuses), member => member.ToString());
            Template.RegisterSafeType(typeof(TestTaskExecutionTypes), member => member.ToString());
            Template.RegisterSafeType(typeof(TestClientStatuses), member => member.ToString());
            Template.RegisterSafeType(typeof(ServerControlCommands), member => member.ToString());
            Template.RegisterSafeType(typeof(TestLabStatuses), member => member.ToString());
            Template.RegisterSafeType(typeof(TestStatuses), member => member.ToString());

            Template.RegisterSafeType(typeof(TestResultDetailTypes), member => member.ToString());

            //Template.RegisterSafeType(typeof(List<ITestResultDetail>), member => member.ToString());
            //Template.RegisterSafeType(typeof(List<TestResultDetail>), member => member.ToString());
            // var list = new List<ITestResultDetail>();
            // list.Count
            // list[]
            //Template.RegisterSafeType(typeof(List<ITestResultDetail>), new[] { "Count" });
            //Template.RegisterSafeType(typeof(List<TestResultDetail>), new[] { "Count" });

            // specific types
            Template.RegisterSafeType(typeof(TestSuite), new[] { "Id", "Name", "Status", "Description", "TestScenarios", "PlatformId", "Statistics", "TimeSpent", "Timestamp", "Tags", "Statistics.All", "Statistics.Passed", "GetAll", "GetPassed", "GetFailed", "GetPassedButWithBadSmell", "GetNotTested" });
            Template.RegisterSafeType(typeof(TestScenario), new[] { "Id", "Name", "Status", "Description", "TestResults", "PlatformId", "Statistics", "TimeSpent", "Timestamp", "Tags", "TestCases", "Statistics.All", "Statistics.Passed", "GetAll", "GetPassed", "GetFailed", "GetPassedButWithBadSmell", "GetNotTested" });
            Template.RegisterSafeType(typeof(TestResult), new[] { "Id", "Name", "Status", "Description", "Origin", "PlatformId", "Timestamp", "Details", "ScriptName", "LineNumber", "Position", "Error", "Code", "Parameters", "TimeSpent", "Generated", "Screenshot", "ListDetailNames" });
            // Template.RegisterSafeType(typeof(TestResult), new[] { "Id", "Name", "Status", "Description", "Origin", "PlatformId", "Timestamp", "Details", "GetDetails", "ScriptName", "LineNumber", "Position", "Error", "Code", "Parameters", "TimeSpent", "Generated", "Screenshot", "ListDetailNames" });
            // Template.RegisterSafeType(typeof(TestResult), new[] { "Id", "Name", "Status", "Description", "Origin", "PlatformId", "Timestamp", "Details", "TestResultDetails", "ScriptName", "LineNumber", "Position", "Error", "Code", "Parameters", "TimeSpent", "Generated", "Screenshot", "ListDetailNames" });
            Template.RegisterSafeType(typeof(TestResultDetail), new[] { "Name", "Timestamp", "GetDetail", "DetailStatus", "DetailType", "TextDetail", "ErrorDetail", "ScreenshotDetail", "LogDetail", "ExternalData" });
            Template.RegisterSafeType(typeof(ITestSuite), new[] { "Id", "Name", "Status", "Description", "TestScenarios", "PlatformId", "Statistics", "TimeSpent", "Timestamp", "Tags", "Statistics.All", "Statistics.Passed", "GetAll", "GetPassed", "GetFailed", "GetPassedButWithBadSmell", "GetNotTested" });
            Template.RegisterSafeType(typeof(ITestScenario), new[] { "Id", "Name", "Status", "Description", "TestResults", "PlatformId", "Statistics", "TimeSpent", "Timestamp", "Tags", "TestCases", "Statistics.All", "Statistics.Passed", "GetAll", "GetPassed", "GetFailed", "GetPassedButWithBadSmell", "GetNotTested" });
            Template.RegisterSafeType(typeof(ITestResult), new[] { "Id", "Name", "Status", "Description", "Origin", "PlatformId", "Timestamp", "Details", "ScriptName", "LineNumber", "Position", "Error", "Code", "Parameters", "TimeSpent", "Generated", "Screenshot", "ListDetailNames" });
            // Template.RegisterSafeType(typeof(ITestResult), new[] { "Id", "Name", "Status", "Description", "Origin", "PlatformId", "Timestamp", "Details", "GetDetails", "ScriptName", "LineNumber", "Position", "Error", "Code", "Parameters", "TimeSpent", "Generated", "Screenshot", "ListDetailNames" });
            // Template.RegisterSafeType(typeof(ITestResult), new[] { "Id", "Name", "Status", "Description", "Origin", "PlatformId", "Timestamp", "Details", "TestResultDetails", "ScriptName", "LineNumber", "Position", "Error", "Code", "Parameters", "TimeSpent", "Generated", "Screenshot", "ListDetailNames" });
            Template.RegisterSafeType(typeof(ITestResultDetail), new[] { "Name", "Timestamp", "GetDetail", "DetailStatus", "DetailType", "TextDetail", "ErrorDetail", "ScreenshotDetail", "LogDetail", "ExternalData" });
            // Template.RegisterSafeType(typeof(TestWorkflow), new[] { "Id", "Name", "TestLabId", "Description", "ParametersPageName" });
            Template.RegisterSafeType(typeof(ITestWorkflow), new[] { "Id", "Name", "TestLabId", "Description", "ParametersPageName", "DefaultData", "IsDefault" }); // ??
            Template.RegisterSafeType(typeof(TestWorkflow), new[] { "Id", "Name", "TestLabId", "Description", "ParametersPageName", "DefaultData", "IsDefault" });
            // Template.RegisterSafeType(typeof(ITestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "StartType", "Data", "TestSuites", "StartTime", "TimeTaken", "GetTestLabName" });
            // Template.RegisterSafeType(typeof(TestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "StartType", "Data", "TestSuites", "StartTime", "TimeTaken", "GetTestLabName" });
            // Template.RegisterSafeType(typeof(ITestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "StartType", "Data", "TestSuites", "StartTime", "GetTimeTaken", "GetTestLabName" });
            // Template.RegisterSafeType(typeof(TestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "StartType", "Data", "TestSuites", "StartTime", "GetTimeTaken", "GetTestLabName" });
            // Template.RegisterSafeType(typeof(ITestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "StartType", "Data", "TestSuites", "StartTime", "GetTimeTaken", "GetTestLabName", "TestPlatforms", "CreatedTime", "BeforeActions", "AfterActions", "CancelActions", "FailureActions" });
            Template.RegisterSafeType(typeof(ITestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "TestStatus", "StartType", "Data", "TestSuites", "StartTime", "GetTimeTaken", "GetTestLabName", "TestPlatforms", "CreatedTime", "BeforeActions", "AfterActions", "CancelActions", "FailureActions" });
            // Template.RegisterSafeType(typeof(TestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "StartType", "Data", "TestSuites", "StartTime", "GetTimeTaken", "GetTestLabName", "TestPlatforms", "CreatedTime", "BeforeActions", "AfterActions", "CancelActions", "FailureActions" });
            Template.RegisterSafeType(typeof(TestRun), new[] { "Id", "Name", "WorkflowId", "TestLabId", "Description", "Status", "TestStatus", "StartType", "Data", "TestSuites", "StartTime", "GetTimeTaken", "GetTestLabName", "TestPlatforms", "CreatedTime", "BeforeActions", "AfterActions", "CancelActions", "FailureActions" });
            // Template.RegisterSafeType(typeof(CommonData), new[] { "Data" });
            Template.RegisterSafeType(typeof(CommonData), new[] { "Data" });
            Template.RegisterSafeType(typeof(ICommonData), new[] { "Data" });
            Template.RegisterSafeType(typeof(ICodeBlock), new[] { "Code" });
            Template.RegisterSafeType(typeof(CodeBlock), new[] { "Code" });
            Template.RegisterSafeType(typeof(TestLab), new[] { "Id", "Name", "Description", "Status" });
            // Template.RegisterSafeType(typeof(TestTask), new[] { "Id", "Name", "StartTime", "TaskStatus", "TaskFinished", "TaskResult", "TimeTaken", "ClientId", "GetTimeTaken" });
            Template.RegisterSafeType(typeof(TestTask), new[] { "Id", "Name", "StartTime", "TaskStatus", "TaskFinished", "TaskResult", "TimeTaken", "ClientId", "GetTimeTaken", "IsActive", "IsCritical", "IsCancel" });
            Template.RegisterSafeType(typeof(TestClient), new[] { "Id", "Hostname", "Fqdn", "Username", "CustomString", "Status", "TaskId", "TaskName", "DetailedStatus" });
            // Template.RegisterSafeType(typeof(CommonDataItem), new[] { "Key", "Value" });
            Template.RegisterSafeType(typeof(ICommonDataItem), new[] { "Key", "Value" });
            Template.RegisterSafeType(typeof(CommonDataItem), new[] { "Key", "Value" });
            Template.RegisterSafeType(typeof(TestStat), new[] { "All", "Passed", "Failed", "PassedButWithBadSmell", "NotTested", "TimeSpent" });
            Template.RegisterSafeType(typeof(TestStat), member => member.ToString());

            //RegisterViewModel(typeof(ITestResult));
            //RegisterViewModel(typeof(TestResult));
            //RegisterViewModel(typeof(ITestRun));
            //RegisterViewModel(typeof(TestRun));
            //RegisterViewModel(typeof(ICommonData));
            //RegisterViewModel(typeof(CommonData));

            // just for copying the Nancy.ViewEngines.DotLiquid assembly to dependant projects
            var drop = new DynamicDrop(new ExpandoObject());
        }
示例#20
0
        public void Should_return_model_value_when_property_name_is_valid_and_model_is_dynamicdictionary()
        {
            // Given
            var model = new DynamicDictionary();
            model["Name"] = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldEqual("Nancy");
        }
示例#21
0
        public void Should_unwrap_dynamicdictionaryvalue_when_model_is_dynamicdictionary()
        {
            // Given
            var model = new DynamicDictionary();
            model["Name"] = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldBeOfType<string>();
        }
示例#22
0
        public void Should_return_null_when_called_with_invalid_property_name_and_model_is_dynamicdictionary()
        {
            // Given
            var model = new DynamicDictionary();
            model["Name"] = "Nancy";

            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("age");

            // Then
            result.ShouldBeNull();
        }
示例#23
0
        public void Should_return_model_value_when_property_name_is_valid_and_model_is_object()
        {
            // Given
            var model = new FakeModel { Name = "Nancy" };
            var drop = new DynamicDrop(model);

            // When
            var result = drop.BeforeMethod("Name");

            // Then
            result.ShouldEqual("Nancy");
        }