Esempio n. 1
0
        public void TestEditRiskFactorTypeGroup()
        {
            RiskFactorTypeGroup group;
            string name = "Edit Risk Factor Type Group Test";
            int groupId = 1;

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                RiskFactorTypeGroupRepository repository = new RiskFactorTypeGroupRepository(context);

                group = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == groupId).FirstOrDefault();
                group.Name = name;

                repository.SaveChanges();
            }

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                RiskFactorTypeGroupRepository repository = new RiskFactorTypeGroupRepository(context);
                group = repository.RiskFactorTypeGroups().Where(g => g.Name == name).FirstOrDefault();

                Assert.AreEqual(groupId, group.RiskFactorTypeGroupID);

            }
        }
Esempio n. 2
0
        public void TestMoveRiskFactorTypeGroup()
        {
            RiskFactorTypeGroup child;
            RiskFactorTypeGroup parent;
            RiskFactorTypeGroup newParent;

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                RiskFactorTypeGroupRepository repository = new RiskFactorTypeGroupRepository(context);

                child = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == 3).FirstOrDefault();
                parent = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == 1).FirstOrDefault();
                newParent = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == 2).FirstOrDefault();

                Assert.AreEqual(parent, child.RiskFactorTypeGroupParent);

                repository.Move(child, newParent);
                repository.SaveChanges();

            }

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                RiskFactorTypeGroupRepository repository = new RiskFactorTypeGroupRepository(context);

                child = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == 3).FirstOrDefault();
                parent = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == 1).FirstOrDefault();
                newParent = repository.RiskFactorTypeGroups().Where(g => g.RiskFactorTypeGroupID == 2).FirstOrDefault();

                Assert.AreEqual(newParent, child.RiskFactorTypeGroupParent);

                Assert.AreEqual(UserName, child.ModifiedBy);
                Assert.AreEqual(DateTime.MinValue, child.StartTime);
                Assert.AreEqual(DateTime.MaxValue, child.EndTime);
                Assert.AreEqual(true, child.Latest);

            }
        }
Esempio n. 3
0
        public void TestNewRiskFactorTypeGroup()
        {
            string name = "New Scenario Group Test";
            int parentId = 1;

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                RiskFactorTypeGroupRepository repository = new RiskFactorTypeGroupRepository(context);

                RiskFactorTypeGroup parent = context.RiskFactorTypeGroups.Find(parentId);
                RiskFactorTypeGroup newItem = repository.Add(parent);
                newItem.Name = name;

                repository.SaveChanges();
            }

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                RiskFactorTypeGroupRepository repository = new RiskFactorTypeGroupRepository(context);

                Assert.AreEqual(1, repository.RiskFactorTypeGroups().Where(a => a.Name == name).Count());

                RiskFactorTypeGroup group = repository.RiskFactorTypeGroups().Where(a => a.Name == name).FirstOrDefault();

                Assert.AreEqual(parentId, group.RiskFactorTypeGroupParentID);
                Assert.AreEqual(EntityStatus.Approved, group.Status);
                Assert.AreNotEqual(DateTime.MinValue, group.StartTime);
                Assert.AreEqual(DateTime.MaxValue, group.EndTime);
                Assert.AreEqual(true, group.Latest);

            }
        }