コード例 #1
0
        public void ModelKeys1()
        {
            var keys = EntityFrameworkHelper.PrimaryKeyNames <SingleKey>();

            Assert.That(keys, Has.Count.EqualTo(1));
            Assert.AreEqual(keys.First(), "StudentKey");
        }
コード例 #2
0
        public void ModelKeys2()
        {
            var keys = EntityFrameworkHelper.PrimaryKeyNames <DoubleKey>();

            Assert.That(keys, Has.Count.EqualTo(2));
            Assert.AreEqual(keys.First(), "StudentKey");
            Assert.AreEqual(keys.Last(), "AdmissionNum");
        }
コード例 #3
0
        public void ModelKeys3()
        {
            var keys = EntityFrameworkHelper.PrimaryKeyNames <TripleKey>();

            Assert.That(keys, Has.Count.EqualTo(3));
            Assert.AreEqual(keys.First(), "StudentKey");
            Assert.AreEqual(keys.Skip(1).First(), "AdmissionNum");
            Assert.AreEqual(keys.Last(), "Guid");
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        public void ModelKeys0()
        {
            var keys = EntityFrameworkHelper.PrimaryKeyNames <EntityKeyExpressionTests>();

            Assert.That(keys, Has.Count.Zero);
        }