public void VerifyIsolationInMemory()
        {
            {
                using IWindsorContainer c = new WindsorContainer();

                c.AddDbContext<SampleContext>()
                    .UseInMemory();

                var ctx1 = c.Resolve<SampleContext>();

                Assert.That(ctx1.ModelIntKeys, Is.Empty);

                ctx1.ModelIntKeys.Add(new ModelIntKey { Id = 1, Name = "test" });
                ctx1.SaveChanges();

                Assert.That(ctx1.ModelIntKeys, Is.Not.Empty);
            }

            {
                // verify second container is blank
                using IWindsorContainer c2 = new WindsorContainer();

                c2.AddDbContext<SampleContext>()
                    .UseInMemory();

                var ctx2 = c2.Resolve<SampleContext>();
                Assert.That(ctx2.ModelIntKeys, Is.Empty);
            }
        }
        public void VerifyCompositeKey_EF_Metadata()
        {
            using IWindsorContainer c = new WindsorContainer();

            c.AddDbContext <SampleContext>()
            .UseInMemory();

            var ctx = c.Resolve <SampleContext>();

            var names = EntityFrameworkHelper.PrimaryKeyNames <CompositeStringKey>(ctx);

            Assert.That(names.Count() == 2);
            Assert.AreEqual(names.First(), "Id");
            Assert.AreEqual(names.Last(), "Name");
        }
        public void PrimaryKeyExpression_2_ViaContext()
        {
            using IWindsorContainer c = new WindsorContainer();

            c.AddDbContext <SampleContext>()
            .UseInMemory();

            var ctx = c.Resolve <SampleContext>();

            var record = new CompositeStringKey {
                Id = "1", Name = "123"
            };

            var exp = EntityFrameworkHelper.PrimaryKeyExpression <CompositeStringKey>(ctx);

            Assert.IsTrue(exp(record, new object[] { "1", "123" }));
            Assert.IsFalse(exp(record, new object[] { "2", string.Empty }));
        }
        public void RegisterInMemory()
        {
            using IWindsorContainer c = new WindsorContainer();

            c.AddDbContext<SampleContext>()
                .UseInMemory();

            var ctx1 = c.Resolve<SampleContext>();
            Assert.NotNull(ctx1);

            using IWindsorContainer c2 = new WindsorContainer();

            c2.AddDbContext<SampleContext>()
                .UseInMemory("Test");

            var ctx2 = c2.Resolve<SampleContext>();
            Assert.NotNull(ctx2);
        }