public void IsViolated_ViolatingContext_ChangesProblemMetadatasGivenType()
        {
            var expectedFragment = Fragment.CreateNamed( "expectedFragment");
              var unexpectedFragment = Fragment.CreateNamed( "unexpectedFragment");
              ProblemMetadata problemMetaData = new ProblemMetadata(0, new SourceContext(), expectedFragment, Fragment.CreateNamed( "dummy"));
              IBlacklistManager blackListManager = _mocks.Stub<IBlacklistManager>();
              EqualityPreCondition preCondition = new EqualityPreCondition("testSymbol", expectedFragment, problemMetaData);
              SymbolTable context = new SymbolTable(blackListManager);
              context.MakeSafe("testSymbol", unexpectedFragment);

              preCondition.IsViolated(context);

              Assert.That(problemMetaData.GivenFragment, Is.EqualTo(unexpectedFragment));
        }
        public void HandleViolation_ProblemMetadataGivenButNoViolation_NoProblemAdded()
        {
            var expectedFragment = Fragment.CreateNamed (c_expectedType);
              var givenFragment = Fragment.CreateNamed (c_expectedType);

              IPreCondition preCondition = new CustomInferencePreCondition(c_symbol, expectedFragment, _problemMetadata);
              var context = new SymbolTable(_blacklistManager);
              context.MakeSafe (c_symbol, givenFragment);
              IProblemPipe problemPipe = MockRepository.GenerateMock<IProblemPipe>();

              preCondition.HandleViolation (context, problemPipe);

              problemPipe.AssertWasNotCalled (pipe => pipe.AddProblem (Arg<ProblemMetadata>.Is.Anything));
        }
 public void SetUp()
 {
     _blacklistManager = new IDbCommandBlacklistManagerStub();
       _methodPreConditions = new SymbolTable (_blacklistManager);
       _methodPreConditions.MakeSafe ("x", Fragment.CreateNamed("SqlFragment"));
       _methodPreConditions.MakeSafe ("l", Fragment.CreateLiteral());
       _methodPreConditions.MakeUnsafe ("y");
       _problemPipeStub = new ProblemPipeStub();
       _methodGraphAnalyzer = new MethodGraphAnalyzer (_problemPipeStub);
       _mocks = new MockRepository();
       _methodGraph = _mocks.Stub<IMethodGraph>();
       _methodGraphBuilder = _mocks.Stub<IMethodGraphBuilder>();
       _parameterSymbolTableBuilder = _mocks.Stub<IInitialSymbolTableBuilder>();
 }
        public void HandleViolation_ViolationNotProvoked_KeepsSymbolFragment()
        {
            var expectedFragment = Fragment.CreateNamed (c_expectedType);
              var givenFragment = expectedFragment;

              IPreCondition preCondition = new CustomInferencePreCondition(c_symbol, expectedFragment, _problemMetadata);
              var context = new SymbolTable(_blacklistManager);
              context.MakeSafe (c_symbol, givenFragment);
              IProblemPipe problemPipe = MockRepository.GenerateMock<IProblemPipe>();

              preCondition.HandleViolation (context, problemPipe);

              bool symbolFragmentKept = context.GetFragmentType (c_symbol) == expectedFragment;
              Assert.That (symbolFragmentKept, Is.True);
        }
        public void IsViolated_NamedExpectedNamedGiven_ReturnsFalse()
        {
            var expectedFragment = Fragment.CreateNamed (c_expectedType);

              IPreCondition preCondition = new CustomInferencePreCondition(c_symbol, expectedFragment, _problemMetadata);
              var context = new SymbolTable(_blacklistManager);
              context.MakeSafe (c_symbol, expectedFragment);

              Assert.That (preCondition.IsViolated (context), Is.False);
        }
        public void IsViolated_LiteralExpectedNamedFragmentGiven_ReturnsTrue()
        {
            var expectedFragment = Fragment.CreateLiteral();
              var givenFragment = Fragment.CreateNamed ("unexpected");

              IPreCondition preCondition = new CustomInferencePreCondition(c_symbol, expectedFragment, _problemMetadata);
              var context = new SymbolTable(_blacklistManager);
              context.MakeSafe (c_symbol, givenFragment);

              Assert.That (preCondition.IsViolated (context), Is.True);
        }