コード例 #1
0
        public void Matches_LookupAnalyzer_CallToExecuteOnce()
        {
            var sut = new ResultSet();

            sut.Load("a;b;1");
            var sutMock = new Mock <IResultSetService>();

            sutMock.Setup(s => s.Execute())
            .Returns(sut);
            var sutService = sutMock.Object;

            var assert = new ResultSet();

            assert.Load("a;b");
            var assertMock = new Mock <IResultSetService>();

            assertMock.Setup(s => s.Execute())
            .Returns(assert);
            var assertService = assertMock.Object;

            var mappings = new ColumnMappingCollection()
            {
                new ColumnMapping(new ColumnOrdinalIdentifier(0), ColumnType.Text),
                new ColumnMapping(new ColumnOrdinalIdentifier(1), ColumnType.Text),
            };

            var lookupExists = new LookupReverseExistsConstraint(assertService);
            var analyzer     = new Mock <LookupExistsAnalyzer>(mappings);

            analyzer.Setup(x => x.Execute(It.IsAny <ResultSet>(), It.IsAny <ResultSet>())).Returns(new LookupExistsViolationCollection(null));
            lookupExists.Engine = analyzer.Object;

            //Method under test
            lookupExists.Matches(sutService);

            //Test conclusion
            analyzer.Verify(x => x.Execute(assert, sut), Times.Once());
        }
コード例 #2
0
        public void Matches_ResultSetService_CallToExecuteOnce()
        {
            var candidate = new ResultSet();

            candidate.Load("a;b;1");
            var sutMock = new Mock <IResultSetService>();

            sutMock.Setup(s => s.Execute())
            .Returns(candidate);
            var candidateService = sutMock.Object;

            var assert = new ResultSet();

            assert.Load("a;b");
            var assertMock = new Mock <IResultSetService>();

            assertMock.Setup(s => s.Execute())
            .Returns(assert);
            var assertService = assertMock.Object;

            var mappings = new ColumnMappingCollection()
            {
                new ColumnMapping(new ColumnOrdinalIdentifier(0), ColumnType.Text),
                new ColumnMapping(new ColumnOrdinalIdentifier(1), ColumnType.Text),
            };

            var lookupExists = new LookupReverseExistsConstraint(candidateService);

            lookupExists = lookupExists.Using(mappings);

            //Method under test
            lookupExists.Matches(assertService);

            //Test conclusion
            sutMock.Verify(s => s.Execute(), Times.Once());
            assertMock.Verify(s => s.Execute(), Times.Once());
        }