public void CleanStorageTest()
        {
            // Add some records to all collections
              var app = new Application {Title = "App1"};
              app = Provider.CreateApplicaton(app);

              var person = new Person {Login = "******", Title = "User Clever"};
              person = Provider.CreatePerson(person);

              var module = new Module {AppId = app.Id, Title = "Module1"};
              module = Provider.CreateModule(module);

              var subModule = new SubModule {ModuleId = module.Id, Title = "SubModule1"};
              subModule = Provider.CreateSubModule(subModule);

              var release = new Release {AppId = app.Id, Title = "Release1"};
              release = Provider.CreateRelease(release);

              var revision = new Revision
                       {
                         AppId = app.Id,
                         BugNumber = 10,
                         Rev = 1,
                         Date = DateTime.Now,
                         Type = BugType.Bug,
                         FoundReleaseId = release.Id,
                         TargetReleaseId = release.Id,
                         Severity = BugSeverity.Critical,
                         Priority = 1,
                         Status = BugStatus.Open,
                         ContributorId = person.Id,
                         ModuleId = module.Id,
                         SubModuleId = subModule.Id,
                         Summary = "Summary text"
                       };

              Provider.CreateRevision(revision);

              // Check that everything is added to storage
              Assert.AreNotEqual(0, Provider.GetApplications().Length);
              Assert.AreNotEqual(0, Provider.GetModules(app.Id).Length);
              Assert.AreNotEqual(0, Provider.GetSubModules(module.Id).Length);
              Assert.AreNotEqual(0, Provider.GetStaff().Length);
              //      Assert.AreNotEqual(0, Provider.GetBugs().Length);
              Assert.AreNotEqual(0, Provider.GetRevisions(10).Length);
              //      Assert.AreNotEqual(0, Provider.GetReleases().Length);

              // Clean storage
              Provider.CleanStorage();
              // And check that it is cleared
              Assert.AreEqual(0, Provider.GetApplications().Length);
              Assert.AreEqual(0, Provider.GetModules(app.Id).Length);
              Assert.AreEqual(0, Provider.GetSubModules(module.Id).Length);
              Assert.AreEqual(0, Provider.GetStaff().Length);
              //      Assert.AreEqual(0, Provider.GetBugs().Length);
              Assert.AreEqual(0, Provider.GetRevisions(10).Length);
              //      Assert.AreEqual(0, Provider.GetReleases().Length);
        }
        ////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates new release.
        /// </summary>
        public DTO.Release CreateRelease(DTO.Release relDTO)
        {
            // Map DTO to EDM
            EDM.Release relEDM = s_relCopier.Copy(relDTO);

            // Insert application
            using (DbManager db = new DbManager())
            {
                db.SetCommand(
                    @"
          INSERT INTO Releases (release_title, app_id) VALUES (@release_title, @app_id) 
          SELECT Cast(SCOPE_IDENTITY() as int) release_id",
                    db.CreateParameters(relEDM, new[] { "release_id" }, null, null)).
                ExecuteObject(relEDM);
            }

            // Map EDM to DTO
            relDTO = s_relCopier.Copy(relEDM);

            return(relDTO);
        }
        public void GetRevisionsTest()
        {
            // Add some records to all collections
              var app = new Application { Title = "App1" };
              app = Provider.CreateApplicaton(app);

              var contributor = new Person { Login = "******", Title = "Contributor" };
              contributor = Provider.CreatePerson(contributor);

              var leader = new Person { Login = "******", Title = "Leader" };
              leader = Provider.CreatePerson(leader);

              var dev = new Person { Login = "******", Title = "Developer" };
              dev = Provider.CreatePerson(dev);

              var tester = new Person { Login = "******", Title = "QM" };
              tester = Provider.CreatePerson(tester);

              var module = new Module { AppId = app.Id, Title = "Module1" };
              module = Provider.CreateModule(module);

              var subModule = new SubModule { ModuleId = module.Id, Title = "SubModule1" };
              subModule = Provider.CreateSubModule(subModule);

              var release = new Release { AppId = app.Id, Title = "Release1" };
              release = Provider.CreateRelease(release);

              var revision1 = Provider.CreateRevision(
            new Revision
              {
            AppId = app.Id,
            BugNumber = 10,
            Rev = 1,
            Date = DateTime.Now,
            Type = BugType.Bug,
            FoundReleaseId = release.Id,
            TargetReleaseId = release.Id,
            Severity = BugSeverity.Critical,
            Priority = 1,
            Status = BugStatus.Open,
            ContributorId = contributor.Id,
            ModuleId = module.Id,
            SubModuleId = subModule.Id,
            Summary = "Summary text"
              });

              var revision2 = Provider.CreateRevision(
            new Revision
              {
            AppId = app.Id,
            BugNumber = 10,
            Rev = 2,
            Date = DateTime.Now.Date,
            Type = BugType.Bug,
            FoundReleaseId = release.Id,
            TargetReleaseId = release.Id,
            Severity = BugSeverity.Critical,
            Priority = 1,
            Status = BugStatus.Verified,
            ContributorId = contributor.Id,
            TeamLeaderId = leader.Id,
            DeveloperId = dev.Id,
            TesterId = tester.Id,
            ModuleId = module.Id,
            SubModuleId = subModule.Id,
            Summary = "Summary text 2"
              });

              Provider.CreateRevision(
            new Revision
              {
            AppId = app.Id,
            BugNumber = 12,
            Rev = 1,
            Date = DateTime.Now.Date,
            Type = BugType.Bug,
            Status = BugStatus.Open,
            ContributorId = contributor.Id,
            Summary = "Summary text 2"
              });

              var revisions = Provider.GetRevisions(10);

              Assert.IsNotNull(revisions);
              Assert.AreEqual(2, revisions.Length);
              Assert.AreEqual(revision1, revisions[0]);
              Assert.AreEqual(revision2, revisions[1]);
        }
        public void CreateRevisionTest()
        {
            // Add some records to all collections
              var app = new Application { Title = "App1" };
              app = Provider.CreateApplicaton(app);

              var contributor = new Person { Login = "******", Title = "Contributor" };
              contributor = Provider.CreatePerson(contributor);

              var leader = new Person { Login = "******", Title = "Leader" };
              leader = Provider.CreatePerson(leader);

              var dev = new Person { Login = "******", Title = "Developer" };
              dev = Provider.CreatePerson(dev);

              var tester = new Person { Login = "******", Title = "QM" };
              tester = Provider.CreatePerson(tester);

              var module = new Module { AppId = app.Id, Title = "Module1" };
              module = Provider.CreateModule(module);

              var subModule = new SubModule { ModuleId = module.Id, Title = "SubModule1" };
              subModule = Provider.CreateSubModule(subModule);

              var release = new Release { AppId = app.Id, Title = "Release1" };
              release = Provider.CreateRelease(release);

              var revision1 = new Revision
              {
            AppId = app.Id,
            BugNumber = 10,
            Rev = 1,
            Date = DateTime.Now,
            Type = BugType.Bug,
            FoundReleaseId = release.Id,
            TargetReleaseId = release.Id,
            Severity = BugSeverity.Critical,
            Priority = 1,
            Status = BugStatus.Open,
            ContributorId = contributor.Id,
            ModuleId = module.Id,
            SubModuleId = subModule.Id,
            Summary = "Summary text"
              };

              var actual1 = Provider.CreateRevision(revision1);

              Assert.IsNotNull(actual1);
              Assert.AreEqual(app.Id, actual1.AppId);
              Assert.AreEqual(10, actual1.BugNumber);
              Assert.AreEqual(1, actual1.Rev);
              Assert.AreEqual(revision1.Date, actual1.Date);
              Assert.AreEqual(BugType.Bug, actual1.Type);
              Assert.AreEqual(release.Id, actual1.FoundReleaseId);
              Assert.AreEqual(release.Id, actual1.TargetReleaseId);
              Assert.AreEqual(1, actual1.Priority);
              Assert.AreEqual(BugSeverity.Critical, actual1.Severity);
              Assert.AreEqual(BugStatus.Open, actual1.Status);
              Assert.AreEqual(contributor.Id, actual1.ContributorId);
              Assert.IsFalse(actual1.TeamLeaderId.HasValue);
              Assert.IsFalse(actual1.DeveloperId.HasValue);
              Assert.IsFalse(actual1.TesterId.HasValue);
              Assert.AreEqual(module.Id, actual1.ModuleId);
              Assert.AreEqual(subModule.Id, actual1.SubModuleId);
              Assert.AreEqual(revision1.Summary, actual1.Summary);

              var revision2 = new Revision
              {
            AppId = app.Id,
            BugNumber = 10,
            Rev = 2,
            Date = DateTime.Now,
            Type = BugType.Bug,
            FoundReleaseId = release.Id,
            TargetReleaseId = release.Id,
            Severity = BugSeverity.Critical,
            Priority = 1,
            Status = BugStatus.Verified,
            ContributorId = contributor.Id,
            TeamLeaderId = leader.Id,
            DeveloperId = dev.Id,
            TesterId = tester.Id,
            ModuleId = module.Id,
            SubModuleId = subModule.Id,
            Summary = "Summary text 2"
              };

              var actual2 = Provider.CreateRevision(revision2);

              Assert.IsNotNull(actual2);
              Assert.AreEqual(app.Id, actual2.AppId);
              Assert.AreEqual(10, actual2.BugNumber);
              Assert.AreEqual(2, actual2.Rev);
              Assert.AreEqual(revision2.Date, actual2.Date);
              Assert.AreEqual(BugType.Bug, actual2.Type);
              Assert.AreEqual(release.Id, actual2.FoundReleaseId);
              Assert.AreEqual(release.Id, actual2.TargetReleaseId);
              Assert.AreEqual(1, actual2.Priority);
              Assert.AreEqual(BugSeverity.Critical, actual2.Severity);
              Assert.AreEqual(BugStatus.Verified, actual2.Status);
              Assert.AreEqual(contributor.Id, actual2.ContributorId);
              Assert.AreEqual(leader.Id, actual2.TeamLeaderId);
              Assert.AreEqual(dev.Id, actual2.DeveloperId);
              Assert.AreEqual(tester.Id, actual2.TesterId);
              Assert.AreEqual(module.Id, actual2.ModuleId);
              Assert.AreEqual(subModule.Id, actual2.SubModuleId);
              Assert.AreEqual(revision2.Summary, actual2.Summary);
        }
        public void CreateReleaseTest()
        {
            var app = new Application {Title = "App1"};
              app = Provider.CreateApplicaton(app);

              var release = new Release {AppId = app.Id, Title = "Release1"};
              Release actual = Provider.CreateRelease(release);

              Assert.IsNotNull(actual);
              Assert.AreNotEqual(0, actual.Id);
              Assert.AreEqual(release.Title, actual.Title);
        }