Exemple #1
0
        public void Should_create_schema_for_registered_expressions()
        {
            IDataStore dataStub = MockRepository.GenerateStub <IDataStore>();

            dataStub.Stub(x => x.CreateSchema(null))
            .IgnoreArguments()
            .Callback(new Func <Type[], bool>((t) =>
            {
                t.Should().Have.SameValuesAs(new Type[]
                {
                    typeof(Commit), typeof(BugFix), typeof(ProjectFile)
                });
                return(true);
            }));

            CommitMappingExpression commitExp = mappingDSL.AddCommit("1");

            commitMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(new CommitMappingExpression[] { commitExp });
            bugFixMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(Enumerable.Empty <BugFixMappingExpression>());
            fileMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(Enumerable.Empty <ProjectFileMappingExpression>());
            mapper.RegisterMapper(commitMapperStub);
            mapper.RegisterMapper(bugFixMapperStub);
            mapper.RegisterMapper(fileMapperStub);
            mapper.CreateDataBase = true;

            mapper.Map(data, "1");
        }
Exemple #2
0
        public void Should_map_modifacation_for_modified_file()
        {
            mappingDSL
            .AddCommit("9")
            .AddFile("file1").Modified()
            .AddFile("file2").Modified()
            .Submit();

            CommitMappingExpression commitExp = mappingDSL.AddCommit("10");

            mapper.Map(
                commitExp.File("file2")
                );
            mapper.Map(
                commitExp.AddFile("file3")
                );
            SubmitChanges();

            Queryable <Modification>()
            .Where(m => m.Commit.Revision == "10")
            .Select(m => m.File.Path)
            .ToArray()
            .Should().Have.SameSequenceAs(new string[]
            {
                "file2", "file3"
            });
        }
Exemple #3
0
        public void Should_not_keep_expressions_between_sessions()
        {
            CommitMappingExpression commitExp = mappingDSL.AddCommit("1");

            commitMapperStub = MockRepository.GenerateMock <CommitMapper>(null as IScmData);
            commitMapperStub.Expect(x => x.Map(null))
            .IgnoreArguments()
            .Return(new CommitMappingExpression[] { commitExp })
            .Repeat.Twice();
            mapper.RegisterMapper(commitMapperStub);

            mapper.Map(data, "1");
            mapper.Map(data, "1");
        }
Exemple #4
0
        public void Should_not_keep_expressions_between_sessions()
        {
            CommitMappingExpression commitExp = data.UsingSession(
                s => s.MappingDSL().AddCommit("1"));

            commitMapper
            .Map(Arg.Any <RepositoryMappingExpression>())
            .Returns(new CommitMappingExpression[] { commitExp });

            mapper.RegisterMapper(commitMapper);
            mapper.MapRevision("1");
            mapper.MapRevision("1");

            commitMapper.Received(2)
            .Map(Arg.Any <RepositoryMappingExpression>());
        }
Exemple #5
0
        public void Should_use_output_expression_for_registered_mapper()
        {
            CommitMappingExpression commitExp = mappingDSL.AddCommit("1");

            commitMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(new CommitMappingExpression[] { commitExp });
            bugFixMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(Enumerable.Empty <BugFixMappingExpression>());

            mapper.RegisterMapper(commitMapperStub);
            mapper.RegisterMapper(bugFixMapperStub);

            mapper.Map(data, "1");

            bugFixMapperStub.AssertWasCalled(x => x.Map(commitExp));
        }
Exemple #6
0
        public void Should_use_output_expression_for_registered_mapper()
        {
            CommitMappingExpression commitExp = data.UsingSession(
                s => s.MappingDSL().AddCommit("1"));

            commitMapper
            .Map(Arg.Any <RepositoryMappingExpression>())
            .Returns(new CommitMappingExpression[] { commitExp });
            bugFixMapper
            .Map(Arg.Any <CommitMappingExpression>())
            .Returns(Enumerable.Empty <BugFixMappingExpression>());

            mapper.RegisterMapper(commitMapper);
            mapper.RegisterMapper(bugFixMapper);
            mapper.MapRevision("1");

            bugFixMapper.Received(1)
            .Map(Arg.Is(commitExp));
        }
Exemple #7
0
        public void Can_use_the_same_expression_for_several_mappers()
        {
            CommitMappingExpression commitExp = mappingDSL.AddCommit("1");

            commitMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(new CommitMappingExpression[] { commitExp });
            bugFixMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(Enumerable.Empty <BugFixMappingExpression>());
            fileMapperStub.Stub(x => x.Map(null))
            .IgnoreArguments()
            .Return(Enumerable.Empty <ProjectFileMappingExpression>());

            mapper.RegisterMapper(commitMapperStub);
            mapper.RegisterMapper(bugFixMapperStub);
            mapper.RegisterMapper(fileMapperStub);

            mapper.Map(data, "1");

            fileMapperStub.AssertWasCalled(x => x.Map(commitExp));
        }