public void validate_positive_case_with_two_properties()
        {
            DatabaseDriver.GetFullFastPackContainer().ExecuteInTransaction <IContainer>(c =>
            {
                var session = c.GetInstance <ISession>();
                session.Save(new Case {
                    Identifier = "something",
                    CaseType   = "Open"
                });
                session.Flush();

                var rule    = c.UniqueRuleForProperties <Case>(x => x.Identifier, x => x.CaseType);
                var context = c.ValidationContextFor(new Case {
                    Identifier = "something",
                    CaseType   = "Open"
                });

                rule.ValidateAgainstSession(session, context);

                context.Notification.MessagesFor <Case>(x => x.Identifier).Single()
                .StringToken.ShouldEqual(FastPackKeys.FIELD_MUST_BE_UNIQUE);

                context.Notification.MessagesFor <Case>(x => x.CaseType).Single()
                .StringToken.ShouldEqual(FastPackKeys.FIELD_MUST_BE_UNIQUE);
            });
        }
예제 #2
0
 public void SetUp()
 {
     container = DatabaseDriver.GetFullFastPackContainer();
     container.Configure(x =>
     {
         x.UseOnDemandNHibernateTransactionBoundary();
     });
 }
예제 #3
0
        public void try_to_build_out_the_test_harness_case_grid()
        {
            var container = DatabaseDriver.GetFullFastPackContainer();

            container.ExecuteInTransaction <CaseController>(x =>
            {
                Debug.WriteLine(x.AllCases().ToString());
            });
        }
예제 #4
0
        public void try_to_build_out_the_test_harness_case_grid()
        {
            var container = DatabaseDriver.GetFullFastPackContainer();

            container.Configure(x => x.For <ICurrentHttpRequest>().Use <FakeCurrentHttpRequest>());
            container.ExecuteInTransaction <CaseController>(x =>
            {
                Debug.WriteLine(x.AllCases().ToString());
            });
        }
예제 #5
0
        public void SetUp()
        {
            requestData = new InMemoryRequestData();

            container = DatabaseDriver.GetFullFastPackContainer();
            container.Configure(x =>
            {
                x.UseOnDemandNHibernateTransactionBoundary();
                x.For <IRequestData>().Use(requestData);
            });
        }
예제 #6
0
        protected void beforeEach()
        {
            DatabaseDriver.GetFullFastPackContainer();

            using (var container = DatabaseDriver.ContainerWithDatabase())
            {
                container.Configure(x => x.UseOnDemandNHibernateTransactionBoundary());
                var session = container.GetInstance <ISession>();
                xxx(session, container);
            }
        }
        public void validate_negative_case()
        {
            using (var container = DatabaseDriver.GetFullFastPackContainer().GetNestedContainer())
            {
                container.Configure(x => x.UseOnDemandNHibernateTransactionBoundary());

                var rule    = container.UniqueRuleForProperties <Site>(x => x.Name);
                var context = container.ValidationContextFor(new Site {
                    Name = "something"
                });
                rule.Validate(context);

                context.Notification.IsValid().ShouldBeTrue();
            }
        }
        public void validate_negative_case_with_two_properties()
        {
            DatabaseDriver.GetFullFastPackContainer().ExecuteInTransaction <IContainer>(c =>
            {
                var session = c.GetInstance <ISession>();
                session.Save(new Case {
                    Identifier = "something", CaseType = "Open"
                });
                session.Flush();

                var rule    = c.UniqueRuleForProperties <Case>(x => x.Identifier, x => x.CaseType);
                var context = c.ValidationContextFor(new Case
                {
                    Identifier = "something",
                    CaseType   = "different"
                });

                rule.ValidateAgainstSession(session, context);

                context.Notification.IsValid().ShouldBeTrue();
            });
        }