예제 #1
0
        public void ShouldThrowExceptionWhenCreatingGivenNullConfiguration()
        {
            Given.Configuration = null;
            WhenLastActionDeferred(Creating);

            ThenLastAction.ShouldThrow <ArgumentNullException>();
        }
예제 #2
0
        public void ShouldThrowExceptionWhenCreatingGivenNullScripts()
        {
            Given.Scripts = null;
            WhenLastActionDeferred(Creating);

            ThenLastAction.ShouldThrow <ArgumentNullException>();
        }
        public void ShouldThrowArgumentExceptionWhenCreatingInstanceGivenNullString()
        {
            Given.Text = null;
            WhenLastActionDeferred(Creating);

            ThenLastAction.ShouldThrow <ArgumentNullException>();
        }
예제 #4
0
        public void ShouldHaveActionActionAvailableThroughProperty_WhenExpectingAnException()
        {
            WhenLastActionDeferred(Exploding);

            ThenLastAction.Should().NotBeNull();
            ThenLastAction.Should().Throw <Exception>("Did I do that?");
        }
예제 #5
0
        public void ShouldThrowException_WhenParsing_GivenFirstItemIsNotAnElement()
        {
            Given.Text = "!A";

            ThrowsExceptionWhen(Parsing);

            ThenLastAction.ShouldThrow <InvalidDataException>();
        }
예제 #6
0
        public void ShouldThrowException_WhenParsing_GivenElementsAtRootDepth()
        {
            Given.Text = "A\r\nB";

            ThrowsExceptionWhen(Parsing);

            ThenLastAction.ShouldThrow <InvalidDataException>();
        }
        public void ShouldThrowException_WhenBuildingDependencies_GivenNonExistentDependency()
        {
            Given.Values = new Builder().WithItem("A").IsDepedentOn("b").Build();

            WhenLastActionDeferred(BuildingDependencies);

            ThenLastAction.ShouldThrow <KeyNotFoundException>();
        }
        public void ShouldThrow_WhenCreatingMemberProperty_GivenNonPublicPropertyInfo()
        {
            Given.PropertyInfo1 = typeof(SomeType).GetProperty("NotSupportedProperty", BindingFlags.NonPublic | BindingFlags.Instance);

            WhenLastActionDeferred(CreatingMemberProperty);

            ThenLastAction.ShouldThrow <NotSupportedException>();
        }
예제 #9
0
        public void ShouldThrowException_WhenProcessingUnexpectedBlock()
        {
            Given.Text = "--:: unknown\nselect 1\nGO\n";

            WhenLastActionDeferred(Parsing);

            ThenLastAction.ShouldThrow <InvalidOperationException>();
        }
        public void ShouldThrowFormatExcpetionWhenFormattingWithUnescapedOpeningBrace()
        {
            Given.Text = "Hey {name,";

            WhenLastActionDeferred(Formatting);

            ThenLastAction.ShouldThrow <FormatException>("Opening brace with field expression 'name,' has no closing brace at position 10.");
        }
        public void ShouldThrowFormatExcpetionWhenFormattingWithEmptyBraces()
        {
            Given.Text = "{}";

            WhenLastActionDeferred(Formatting);

            ThenLastAction.ShouldThrow <FormatException>("Opening brace with no field name specified at position 1.");
        }
        public void ShouldThrowFormatExcpetionWhenFormattingWithUnescapedClosingBrace()
        {
            Given.Text = "Hey name},";

            WhenLastActionDeferred(Formatting);

            ThenLastAction.ShouldThrow <FormatException>("Unescaped closing brace found at position 9.");
        }
        public void ShouldThrowException_WhenCreating_GivenNullValues()
        {
            Given.Values = null;

            WhenLastActionDeferred(Creating);

            ThenLastAction.ShouldThrow <ArgumentNullException>();
        }
예제 #14
0
        public void ShouldThrowExceptionWhenRequestingPhaseGivenPhaseDoesNotExist()
        {
            Given.RequestedPhase = SqlScriptPhase.Main;

            WhenLastActionDeferred(Validating, RequestingPhase);

            ThenLastAction.ShouldThrow <InvalidOperationException>();
        }
        public void ShouldThrowException_WhenCreatingIEnumerable_GivenDidNotCallPrepare()
        {
            Given.HowMany = 10;

            WhenLastActionDeferred(CreatingIEnumerable);

            ThenLastAction.Should().Throw <InvalidOperationException>();
        }
        public void ShouldThrow_WhenCreatingMemberMethod_GivenNonPublicMethodInfo()
        {
            Given.MethodInfo = typeof(SomeType).GetMethod("NotSupportedFunction", BindingFlags.NonPublic | BindingFlags.Instance);

            WhenLastActionDeferred(CreatingMemberMethod);

            ThenLastAction.ShouldThrow <NotSupportedException>();
        }
예제 #17
0
        public void ShouldThrowException_WhenCreating_GivenNullSettings()
        {
            Given.NullSettings = true;

            WhenLastActionDeferred(Creating);

            ThenLastAction.ShouldThrow <ArgumentNullException>();
        }
        public void ShouldThrowFormatExcpetionWhenFormattingWithUnescapedOpeningBraceAndNoMoreText()
        {
            Given.Text = "Hey {";

            WhenLastActionDeferred(Formatting);

            ThenLastAction.ShouldThrow <FormatException>("Opening brace with no field name specified at position 5.");
        }
예제 #19
0
        public void ShouldThrowException_WhenGettingName()
        {
            Given.Depth = 0;
            Given.Value = string.Empty;

            ThrowsExceptionWhen(GettingName);

            ThenLastAction.ShouldThrow <NotSupportedException>();
        }
        public void ShouldThrownException_WhenBuildingDependencies_GivenMixedCaseAndCaseSensitivity()
        {
            Given.Values   = new Builder().WithItem("A").IsDepedentOn("b").WithItem("B").Build();
            Given.Comparer = StringComparer.CurrentCulture;

            WhenLastActionDeferred(BuildingDependencies);

            ThenLastAction.ShouldThrow <KeyNotFoundException>().WithMessage("Item with key 'A' has dependency 'b', which was not found.");
        }
예제 #21
0
        public void ShouldThrowExceptionWhenCreatingInstanceGivenMissingScriptForPriorityList()
        {
            Given.Configuration = new ProjectConfigJson("Test", "14.06.08.01", new[] { "ScriptA" });
            Given.Scripts       = new List <SourceScript>();

            WhenLastActionDeferred(Creating);

            ThenLastAction.ShouldThrow <InvalidOperationException>();
        }
예제 #22
0
        public void ShouldThrowException_WhenRequestingExecutionMoreThanOnce()
        {
            Given.Text    = "Select 1";
            Given.Keyword = "main";
            Given.Phase   = SqlScriptPhase.Main;

            WhenLastActionDeferred(ParsingSqlTextBlock, RequestingForExecution, RequestingForExecution);

            ThenLastAction.ShouldThrow <InvalidOperationException>().WithMessage("Cannot request execution for script block more than once.");
        }
예제 #23
0
        public void ShouldThrowException_WhenRequestingExecution_GivenUnparsedBlock()
        {
            Given.Text    = "Select 1";
            Given.Keyword = "main";
            Given.Phase   = SqlScriptPhase.Main;

            WhenLastActionDeferred(RequestingForExecution);

            ThenLastAction.ShouldThrow <InvalidOperationException>().WithMessage("Cannot execute invalid script block.");
        }
        public void ShouldThrowException_WhenBuildingDependencies_GivenCircularReference()
        {
            Given.Values = new Builder()
                           .WithItem(1).IsDepedentOn(2)
                           .WithItem(2).IsDepedentOn(5)
                           .WithItem(5).IsDepedentOn(4, 1)
                           .WithItems(3, 4).Build();

            WhenLastActionDeferred(BuildingDependencies);

            ThenLastAction.ShouldThrow <InvalidOperationException>("a circular reference was defined.")
            .WithMessage("a circular reference was detected.  Circular path: \r\n1 -> 2 -> 5 -> 1");
        }
        public void ShouldThrowException_WhenBuildingDependencies_GivenCircularReference()
        {
            Given.Values = new Builder()
                           .WithItem("A").IsDepedentOn("b")
                           .WithItem("B").IsDepedentOn("e")
                           .WithItem("E").IsDepedentOn("D", "A")
                           .WithItems("C", "D")
                           .Build();

            WhenLastActionDeferred(BuildingDependencies);

            ThenLastAction.ShouldThrow <InvalidOperationException>("a circular reference was defined.")
            .WithMessage("a circular reference was detected.  Circular path: \r\nA -> B -> E -> A");
        }
        public void ShouldNotThrowException_WhenPreparing()
        {
            WhenLastActionDeferred(Preparing);

            ThenLastAction.Should().NotThrow();
        }
 public void ShouldThrowExceptionWhenCreatingInstanceGivenNullProject()
 {
     Given.Project = null;
     WhenLastActionDeferred(Creating);
     ThenLastAction.ShouldThrow <ArgumentNullException>();
 }
        public void ShouldThrowException_WhenCreatingModel_GivenDidNotCallPrepare()
        {
            WhenLastActionDeferred(CreatingModel);

            ThenLastAction.Should().Throw <InvalidOperationException>();
        }
예제 #29
0
        public void ShouldThrowException_WhenAccessingName_GivenElement()
        {
            ThrowsExceptionWhen(() => { var value = Then.Target.Value; });

            ThenLastAction.ShouldThrow <NotSupportedException>();
        }
 public void ShouldThrowExceptionWhenCreatingInstanceGivenNullConnectionManager()
 {
     Given.ConnectionManager = null;
     WhenLastActionDeferred(Creating);
     ThenLastAction.ShouldThrow <ArgumentNullException>();
 }