Exemple #1
0
        void ImportLatestLogs(object o)
        {
            UnitOfWork unitOfWork = null;;

            try
            {
                unitOfWork = new UnitOfWork();

                var sourceControl = new SourceControl();
                var houseKeeper   = new HouseKeepingService(unitOfWork, sourceControl);

                int logsImported = houseKeeper.ImportLatestLogs();

                unitOfWork.Save();

                System.Diagnostics.Trace.TraceInformation(logsImported + " revisions imported");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.TraceError("ImportLatestLogs: " + ex);
            }
            finally
            {
                if (unitOfWork != null)
                {
                    unitOfWork.Dispose();
                }
            }
        }
Exemple #2
0
        public void ImportLatestLogs_Inserts_Commits_Since_Last_Imported()
        {
            SourceControlDummy sourceControl = new SourceControlDummy(
                new List <Commit>()
            {
                new Commit()
                {
                    Revision = 0, Author = "mickey", Message = "Commit0", Timestamp = DateTime.Now
                },
                new Commit()
                {
                    Revision = 1, Author = "daffy", Message = "Commit1", Timestamp = DateTime.Now
                }
            });

            using (var uow = new UnitOfWork())
            {
                HouseKeepingService sut = new HouseKeepingService(uow, sourceControl);

                sut.ImportLatestLogs();

                uow.Save();
            }


            using (var uow = new UnitOfWork())
            {
                Assert.AreEqual(2, uow.Context.Commits.Count());
            }

            sourceControl.Commits.Add(new Commit()
            {
                Revision = 2, Author = "donald", Message = "Commit2", Timestamp = DateTime.Now
            });
            sourceControl.Commits.Add(new Commit()
            {
                Revision = 3, Author = "minnie", Message = "Commit3", Timestamp = DateTime.Now
            });
            sourceControl.Commits.Add(new Commit()
            {
                Revision = 4, Author = "pluto", Message = "Commit4", Timestamp = DateTime.Now
            });

            using (var uow = new UnitOfWork())
            {
                HouseKeepingService sut = new HouseKeepingService(uow, sourceControl);

                sut.ImportLatestLogs();

                uow.Save();
            }

            using (var uow = new UnitOfWork())
            {
                Assert.AreEqual(5, uow.Context.Commits.Count());
            }
        }
Exemple #3
0
        public void ImportLatestLogs_No_New_Logs_Leaves_Database_Unchanged()
        {
            SourceControlDummy sourceControl = new SourceControlDummy(
                new List <Commit>()
            {
                new Commit()
                {
                    Revision = 0, Author = "mickey", Message = "Commit0", Timestamp = DateTime.Now
                },
                new Commit()
                {
                    Revision = 1, Author = "daffy", Message = "Commit1", Timestamp = DateTime.Now
                }
            });

            using (var uow = new UnitOfWork())
            {
                HouseKeepingService sut = new HouseKeepingService(uow, sourceControl);

                sut.ImportLatestLogs();

                uow.Save();
            }

            using (var uow = new UnitOfWork())
            {
                Assert.AreEqual(2, uow.Context.Commits.Count());
            }

            using (var uow = new UnitOfWork())
            {
                HouseKeepingService sut = new HouseKeepingService(uow, sourceControl);

                sut.ImportLatestLogs();

                uow.Save();
            }

            using (var uow = new UnitOfWork())
            {
                Assert.AreEqual(2, uow.Context.Commits.Count());
            }
        }