Ejemplo n.º 1
0
        public void TestMigrateFromV0()
        {
            LMTeam team;
            LMTeam origTeam;

            using (Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("spain.ltt")) {
                origTeam = Serializer.Instance.Load <LMTeam> (resource);
            }

            team    = origTeam.Clone();
            team.ID = Guid.Empty;
            Assert.AreEqual(0, team.Version);
            TeamMigration.Migrate(team);
            Assert.AreNotEqual(Guid.Empty, team.ID);
            Assert.AreEqual(1, team.Version);

            team    = origTeam.Clone();
            team.ID = Guid.Empty;
            var  teamNameToID = new Dictionary <string, Guid> ();
            Guid id           = Guid.NewGuid();

            teamNameToID [team.TeamName] = id;
            TeamMigration.Migrate0(team, teamNameToID);
            Assert.AreEqual(id, team.ID);
        }
Ejemplo n.º 2
0
        public void Migrate_FromV0ToV2_Ok()
        {
            // Arrange
            LMTeam team;
            LMTeam origTeam;

            using (Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("spain.ltt")) {
                origTeam = Serializer.Instance.Load <LMTeam> (resource);
            }

            team    = origTeam.Clone();
            team.ID = Guid.Empty;

            mockPreview.Setup(p => p.CreatePreview(team)).Returns(new Image(1, 1));

            // Act
            Assert.AreEqual(0, team.Version);
            TeamMigration.Migrate(team);

            // Assert
            Assert.AreNotEqual(Guid.Empty, team.ID);
            Assert.AreEqual(2, team.Version);
            Assert.IsNotNull(team.Preview);

            team    = origTeam.Clone();
            team.ID = Guid.Empty;
            var  teamNameToID = new Dictionary <string, Guid> ();
            Guid id           = Guid.NewGuid();

            teamNameToID [team.TeamName] = id;
            TeamMigration.Migrate0(team, teamNameToID);

            Assert.AreEqual(id, team.ID);
        }
Ejemplo n.º 3
0
        public void NewTeam_NothingToMigrate_DoNothing()
        {
            // Arrange
            LMTeam team = new LMTeam();

            mockPreview.Setup(p => p.CreatePreview(team)).Returns(new Image(1, 1));

            // Act
            TeamMigration.Migrate(team);

            // Assert
            Assert.IsNull(team.Preview);
            Assert.AreEqual(2, team.Version);
        }
Ejemplo n.º 4
0
 protected override void MigrateStorable(IStorable storable)
 {
     if (storable is Project)
     {
         ProjectMigration.Migrate(storable as LMProject);
     }
     else if (storable is Team)
     {
         TeamMigration.Migrate(storable as LMTeam);
     }
     else if (storable is LMDashboard)
     {
         DashboardMigration.Migrate(storable as LMDashboard);
     }
 }
Ejemplo n.º 5
0
        void MigrateTeams()
        {
            if (teamsMigrated)
            {
                return;
            }

            var teams = App.Current.TeamTemplatesProvider.Templates;

            foreach (LMTeam t in teams)
            {
                TeamMigration.Migrate(t);
                App.Current.TeamTemplatesProvider.Save(t);
            }

            teamsMigrated = true;
        }
Ejemplo n.º 6
0
        public void MigrateV1_AlreadyMigrated_DoNothing()
        {
            // Arrange
            LMTeam team;
            LMTeam origTeam;

            using (Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("spain.ltt")) {
                origTeam = Serializer.Instance.Load <LMTeam> (resource);
            }

            team = origTeam.Clone();
            TeamMigration.Migrate(team);

            mockPreview.Setup(p => p.CreatePreview(team)).Returns(new Image(1, 1));

            // Act
            Image preview = team.Preview;

            TeamMigration.Migrate1(team);

            // Assert
            Assert.AreSame(preview, team.Preview);
            Assert.AreEqual(2, team.Version);
        }