コード例 #1
0
ファイル: CurveUnitTest.cs プロジェクト: Juliusz/Test
        public void TestNewCurve()
        {
            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                var repository = new CurveRepository(context);

                var details = repository.CurveDetails();

                var newChild = repository.Add(null);
                newChild.Name = "New Curve Test";

                newChild.TargetSystem = context.TargetSystems.Find(1);
                newChild.CurveFamily = context.CurveFamilies.Find(1);

                Assert.AreEqual(EntityStatus.Unapproved, newChild.Status);
                Assert.AreEqual(EntityStatus.Unapproved, newChild.Curve.Status);

                AggregatedValidationResult result = ValidationManager.Context.Validate(newChild);
                Assert.AreEqual(Status.Success, result.StatusCode);
                newChild.Approve(context.UserName);
                context.CurveDetails.Add(newChild);
                repository.SaveChanges();
            }

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                var saved = context.CurveDetails.Single(x => x.Name == "New Curve Test");

                Assert.AreEqual(EntityStatus.Approved, saved.Status);
            }
        }
コード例 #2
0
ファイル: CurveUnitTest.cs プロジェクト: Juliusz/Test
        public void TestRequiredAttributes()
        {
            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                var repository = new CurveRepository(context);

                var newChild = repository.Add(null);
                newChild.Name = "New Curve Test1";
                context.CurveDetails.Add(newChild);

                AggregatedValidationResult result = ValidationManager.Context.Validate(newChild);
                Assert.AreEqual(Status.Failure, result.StatusCode);
            }
        }