Esempio 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);
        }
        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);
        }
        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);
        }
Esempio 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);
     }
 }
        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;
        }
        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);
        }