public void SetUp()
        {
            const int id = 4765;
            const string firstName = "Julie";
            const string lastName = "Li";
            var pet = new Pet {Id = 4987};
            var address = new Address("1234 Happy St", "Winnipeg", "MB", "R3B 2A2");

            _owner = new Owner
            {
                Id = id,
                FirstName = firstName,
                LastName = lastName,
                Address =address
            };

            _owner.AddPet(pet);

            var sameOwnerPlacedIntoSession = new Owner
            {
                Id = id,
                FirstName = firstName,
                LastName = lastName,
                Address = address
            };

            sameOwnerPlacedIntoSession.AddPet(pet);

            var sessionSource = FluentNHibernateMappingTester.GetNHibernateSessionWithWrappedEntity(sameOwnerPlacedIntoSession);
            _persistenceSpecification = new PersistenceSpecification<Owner>(sessionSource, new DomainEntityComparer());
        }
        public void Passed_Transaction_Should_Apply_For_Reference_Saving()
        {
            var transaction = A.Fake<ITransaction>();
            A.CallTo(() => transaction.IsActive).Returns(true);

            var session = A.Fake<ISession>();
            A.CallTo(() => session.Transaction).Returns(transaction);
            A.CallTo(() => session.Get<Cat>(null)).WithAnyArguments()
                .Returns(
                new Cat
                {
                    Name = "Fluffy",
                    CatType = new CatType
                    {
                        Name = "Persian"
                    }
                });


            var spec = new PersistenceSpecification<Cat>(session, new NameEqualityComparer());
            spec.CheckProperty(x => x.Name, "Fluffy");
            spec.CheckReference(x => x.CatType, new CatType { Name = "Persian" });

            spec.VerifyTheMappings();

            A.CallTo(() => session.Transaction).MustHaveHappened(Repeated.Exactly.Twice);
            A.CallTo(() => session.BeginTransaction()).MustNotHaveHappened();
        }
        public void Passed_Transaction_Should_Apply_For_Reference_Saving()
        {
            var transaction = MockRepository.GenerateMock<ITransaction>();
            transaction.Expect(x => x.IsActive).Return(true);

            var session = MockRepository.GenerateMock<ISession>();
            session.Expect(x => x.Transaction).Return(transaction).Repeat.Twice();

            session.Expect(x => x.BeginTransaction()).Repeat.Never();
            session.Expect(s => s.Get<Cat>(null)).IgnoreArguments().Return(
                new Cat
                {
                    Name = "Fluffy",
                    CatType = new CatType
                    {
                        Name = "Persian"
                    }
                });

            var spec = new PersistenceSpecification<Cat>(session, new NameEqualityComparer());
            spec.CheckProperty(x => x.Name, "Fluffy");
            spec.CheckReference(x => x.CatType, new CatType {Name = "Persian"});

            spec.VerifyTheMappings();

            session.VerifyAllExpectations();
        }
Exemple #4
0
        public void TestMethod1()
        {
            // class that can test mappings easily
            var persistenceSpecification = new PersistenceSpecification<User>(Session);

            var mappings = persistenceSpecification.VerifyTheMappings();
        }
        public static PersistenceExpression<Solution> ForSolution(Solution target)
        {
            var file = "{0}-{1}.config".ToFormat(typeof(Solution).Name, Guid.NewGuid());
            var fileSystem = new FileSystem();

            if (fileSystem.FileExists(file))
            {
                fileSystem.DeleteFile(file);
            }

            var writer = ObjectBlockWriter.Basic(new RippleBlockRegistry());
            var contents = writer.Write(target);
            Debug.WriteLine(contents);
            fileSystem.WriteStringToFile(file, contents);

            var reader = SolutionLoader.Reader();

            var specification = new PersistenceSpecification<Solution>(x =>
            {
                var fileContents = fileSystem.ReadStringFromFile(file);
                var readValue = Solution.Empty(); 
                reader.Read(readValue, fileContents);

                fileSystem.DeleteFile(file);

                return readValue;
            });

            specification.Original = target;

            return new PersistenceExpression<Solution>(specification);
        }
        public void PartnerUserSpecification()
        {
            var role = new PersistenceSpecification<RoleEntity>(this.Session)
                .CheckProperty(c => c.Name, this.ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            var user = new PersistenceSpecification<UserEntity>(this.Session)
                .CheckProperty(c => c.Name, this.ShortStringGenerator.GetRandomValue())
                .CheckProperty(c => c.Email, this.ShortStringGenerator.GetRandomValue())
                .CheckEntity(c => c.Role, role)
            .VerifyTheMappings();

            var partner = new PersistenceSpecification<PartnerEntity>(this.Session)
                .CheckProperty(c => c.Name, this.ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            partner.Users.Add(user);

            this.Session.Flush();
            this.Session.Clear();

            user = this.Session.Load<UserEntity>(user.Id);

            Assert.That(user.Partner, Is.Not.Null);
        }
        public void Should_reject_classes_without_a_parameterless_constructor()
        {
            var _spec = new PersistenceSpecification<NoParameterlessConstructorClass>(sessionSource);

            typeof(MissingConstructorException).ShouldBeThrownBy(() =>
                _spec.VerifyTheMappings());
        }
        public void SetUp()
        {
            original = new PersistenceCheckTarget();
            persisted = new PersistenceCheckTarget();

            specification = new PersistenceSpecification<PersistenceCheckTarget>(o => persisted);
            specification.Original = original;
        }
        public void PermissionSpecification()
        {
            var role = new PersistenceSpecification<RoleEntity>(this.Session)
                .CheckProperty(c => c.Name, this.ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            new PersistenceSpecification<PermissionEntity>(this.Session)
                .CheckProperty(c => c.Name, AccessRight.Admin)
                .CheckEntity(c => c.Role, role)
            .VerifyTheMappings();
        }
        public void UserSpecification()
        {
            var role = new PersistenceSpecification<RoleEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            new PersistenceSpecification<UserEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
                .CheckProperty(c => c.Email, ShortStringGenerator.GetRandomValue())
                .CheckEntity(c => c.Role, role)
            .VerifyTheMappings();
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression<Func<ReferenceEntity, object>>)(x => x.ReferenceList));

            referencedEntities = new List<OtherEntity> {new OtherEntity(), new OtherEntity()};

            session = MockRepository.GenerateStub<ISession>();
            session.Stub(x => x.BeginTransaction()).Return(MockRepository.GenerateStub<ITransaction>());
            specification = new PersistenceSpecification<PropertyEntity>(session);

            sut = new ReferenceList<PropertyEntity, OtherEntity>(property, referencedEntities);
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression<Func<ReferenceEntity, OtherEntity>>)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = A.Fake<ISession>();
            A.CallTo(() => session.BeginTransaction()).Returns(A.Dummy<ITransaction>());
            specification = new PersistenceSpecification<PropertyEntity>(session);

            sut = new ReferenceProperty<PropertyEntity, OtherEntity>(property, referencedEntity);
        }
        public void Should_Not_Open_A_New_Transaction_If_One_Is_Passed()
        {
            var transaction = MockRepository.GenerateMock<ITransaction>();
            transaction.Expect(x => x.IsActive).Return(true);

            var session = MockRepository.GenerateMock<ISession>();
            session.Expect(x => x.Transaction).Return(transaction).Repeat.Twice();
            session.Expect(x => x.BeginTransaction()).Repeat.Never();

            var spec = new PersistenceSpecification<Cat>(session);
            spec.VerifyTheMappings();

            session.VerifyAllExpectations();
        }
        public void Should_Open_A_New_Transaction_If_None_Is_Passed()
        {

            var transaction = A.Fake<ITransaction>();
            A.CallTo(() => transaction.IsActive).Returns(false);

            var session = A.Fake<ISession>();
            A.CallTo(() => session.Transaction).Returns(transaction);
            A.CallTo(() => session.BeginTransaction()).Returns(transaction);

            var spec = new PersistenceSpecification<Cat>(session);
            spec.VerifyTheMappings();

            A.CallTo(() => session.Transaction).MustHaveHappened(Repeated.Exactly.Twice);
        }
        public void PermissionRoleSpecification()
        {
            var role = new PersistenceSpecification<RoleEntity>(this.Session)
                .CheckProperty(c => c.Name, this.ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

             var permission = new PersistenceSpecification<PermissionEntity>(this.Session)
                .CheckProperty(c => c.Name, AccessRight.Admin)
                .CheckEntity(c => c.Role, role)
            .VerifyTheMappings();

            this.Session.Evict(permission);
            this.Session.Evict(role);

            role = this.Session.Load<RoleEntity>(role.Id);

            Assert.That(role.Permissions.Count, Is.EqualTo(1));
        }
        public void UserPasswordCredentialSpecification()
        {
            var role = new PersistenceSpecification<RoleEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            var user = new PersistenceSpecification<UserEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
                .CheckProperty(c => c.Email, ShortStringGenerator.GetRandomValue())
                .CheckEntity(c => c.Role, role)
            .VerifyTheMappings();

            var credential = new PersistenceSpecification<UserPasswordCredentialEntity>(Session)
                .CheckProperty(c => c.Login, ShortStringGenerator.GetRandomValue())
                .CheckProperty(c => c.PasswordHash, ShortStringGenerator.GetRandomValue())
                .CheckProperty(c => c.PasswordSalt, ShortStringGenerator.GetRandomValue())
                .CheckEntity(c => c.User, user)
            .VerifyTheMappings();

            Assert.That(credential.User.UserPasswordCredential, Is.Not.Null);
        }
 public virtual void HasRegistered(PersistenceSpecification <T> specification)
 {
 }
Exemple #18
0
    public void TestAMappingForSomething()
    {
        var spec = new PersistenceSpecification <Something> (session);

        spec.VerifyTheMappings();
    }
        protected override void TestMappings(PersistenceSpecification <WebLinksCategory> specification)
        {
            Assertion.NotNull(specification);

            base.TestMappings(specification);
        }
 public void Should_accept_instances_regardless_of_constructor()
 {
     var _spec = new PersistenceSpecification<NoParameterlessConstructorClass>(sessionSource);
     _spec.VerifyTheMappings(new NoParameterlessConstructorClass(123));
 }
        protected override void TestMappings(PersistenceSpecification <Blog> specification)
        {
            Assertion.NotNull(specification);

            base.TestMappings(specification);
        }
 public ISet<OrderProduct> OrderProductTest()
 {
     Product product = ProductMappingTest();
     OrderProduct orderProduct = new PersistenceSpecification<OrderProduct>(Session)
         .CheckProperty(x => x.ProductName, product.Name)
         .CheckProperty(x => x.Product, product)
         .CheckProperty(x => x.Price, 10.00m)
         .CheckProperty(x => x.Count, 10)
         .CheckProperty(x => x.CampaignPrice, 9.99m)
         .CheckProperty(x => x.Summa, 99.90m)
         .VerifyTheMappings();
     return new HashSet<OrderProduct> { orderProduct };
 }
Exemple #23
0
 public PersistenceExpression(PersistenceSpecification <T> specification)
 {
     _specification = specification;
 }
 public ISet<ProductSet> ProductSetMapTest()
 {
     ProductSet productSet = new PersistenceSpecification<ProductSet>(Session)
     .CheckProperty(x => x.Name, "ProductSet1")
     .CheckProperty(x => x.Description, "Description1")
     //.CheckReference(x => x.Campaign, CampaignMappingTest())
     .VerifyTheMappings();
     return new HashSet<ProductSet> { productSet };
 }
        public void AchTransactionSpecification()
        {
            var partner = new PersistenceSpecification<PartnerEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            new PersistenceSpecification<PartnerDetailEntity>(Session)
                .CheckProperty(c => c.CompanyIdentification, new StringGenerator(10, 10).GetRandomValue())
                .CheckProperty(c => c.CompanyName, new StringGenerator(5, 16).GetRandomValue())
                .CheckProperty(c => c.DfiIdentification, new StringGenerator(8, 8).GetRandomValue())
                .CheckProperty(c => c.Destination, new StringGenerator(5, 23).GetRandomValue())
                .CheckProperty(c => c.DiscretionaryData, new StringGenerator(5, 20).GetRandomValue())
                .CheckProperty(c => c.ImmediateDestination, new StringGenerator(5, 10).GetRandomValue())
                .CheckProperty(c => c.OriginOrCompanyName, new StringGenerator(5, 23).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();

            new PersistenceSpecification<AchTransactionEntity>(Session)
                .CheckProperty(c => c.IndividualIdNumber, new StringGenerator(15, 15).GetRandomValue())
                .CheckProperty(c => c.ReceiverName, new StringGenerator(22, 22).GetRandomValue())
                .CheckProperty(c => c.Amount, (decimal)123.45)
                .CheckProperty(c => c.CallbackUrl, new StringGenerator(20, 255).GetRandomValue())
                .CheckProperty(c => c.DfiAccountId, new StringGenerator(17, 17).GetRandomValue())
                .CheckProperty(c => c.EntryClassCode, new StringGenerator(3, 3).GetRandomValue())
                .CheckProperty(c => c.EntryDate, DateTime.Now)
                .CheckProperty(c => c.EntryDescription, new StringGenerator(5, 10).GetRandomValue())
                .CheckProperty(c => c.PaymentRelatedInfo, new StringGenerator(4, 84).GetRandomValue())
                .CheckProperty(c => c.ServiceClassCode, new StringGenerator(3, 3).GetRandomValue())
                .CheckProperty(c => c.TransactionCode, new StringGenerator(2, 2).GetRandomValue())
                .CheckProperty(c => c.TransactionStatus, AchTransactionStatus.Received)
                .CheckProperty(c => c.TransitRoutingNumber, new StringGenerator(9, 9).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();
        }
 public override void HasRegistered(PersistenceSpecification <T> specification)
 {
     specification.TransactionalSave(Value);
 }
Exemple #27
0
 /// <summary>
 ///   <para></para>
 /// </summary>
 /// <param name="specification"></param>
 /// <exception cref="ArgumentNullException">If <paramref name="specification"/> is a <c>null</c> reference.</exception>
 protected abstract void TestMappings(PersistenceSpecification <ENTITY> specification);
Exemple #28
0
 public static PersistenceSpecification <T> CheckEntity <T>(
     this PersistenceSpecification <T> spec, Expression <Func <T, object> > expression, IEntity propertyValue)
 {
     return(spec.CheckProperty(expression, propertyValue, new EntityComparer()));
 }
        private AchTransactionEntity CreateAchTransaction(
            string callbackUrl = null,
            string dfiAccountId = null,
            string entryClassCode = null,
            string entryDescription = null,
            string individualIdNumber = null,
            string paymentRelatedInfo = null,
            string receiverName = null,
            string serviceClassCode = null,
            string transactionCode = null,
            string transitRoutingNumber = null)
        {
            var defaultPartner = new PersistenceSpecification<PartnerEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
                .VerifyTheMappings();

            var transaction = new AchTransactionEntity
                                  {
                                      DfiAccountId = dfiAccountId ?? "12345678901234567",
                                      CallbackUrl = callbackUrl ?? "http://test.com",
                                      EntryDescription = entryDescription ?? "PAYROLL",
                                      IndividualIdNumber = individualIdNumber ?? "123456789012345",
                                      ReceiverName = receiverName ?? "SomeName",
                                      TransitRoutingNumber = transitRoutingNumber ?? "123456789",
                                      EntryClassCode = entryClassCode ?? "PPD",
                                      ServiceClassCode = serviceClassCode ?? "200",
                                      TransactionCode = transactionCode ?? "22",
                                      PaymentRelatedInfo = paymentRelatedInfo ?? "dsdfdsfsdf",
                                      Partner = defaultPartner,
                                      Amount = (decimal)123.00,
                                      TransactionStatus = AchTransactionStatus.Received,
                                      EntryDate = DateTime.Now
                                  };
            var manager = Locator.GetInstance<IAchTransactionManager>();
            manager.Create(transaction);

            return transaction;
        }
        public void should_not_be_equal_without_the_equality_comparer()
        {
            _spec = new PersistenceSpecification<Cat>(_sessionSource);

            typeof(ApplicationException).ShouldBeThrownBy(() =>
                _spec.CheckList(x => x.AllKittens, _cat.AllKittens).VerifyTheMappings());
        }
        public void AchFileSpecification()
        {
             var partner = new PersistenceSpecification<PartnerEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            new PersistenceSpecification<PartnerDetailEntity>(Session)
                .CheckProperty(c => c.CompanyIdentification, new StringGenerator(10, 10).GetRandomValue())
                .CheckProperty(c => c.CompanyName, new StringGenerator(5, 16).GetRandomValue())
                .CheckProperty(c => c.DfiIdentification, new StringGenerator(8, 8).GetRandomValue())
                .CheckProperty(c => c.Destination, new StringGenerator(5, 23).GetRandomValue())
                .CheckProperty(c => c.DiscretionaryData, new StringGenerator(5, 20).GetRandomValue())
                .CheckProperty(c => c.ImmediateDestination, new StringGenerator(5, 10).GetRandomValue())
                .CheckProperty(c => c.OriginOrCompanyName, new StringGenerator(5, 23).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();

            new PersistenceSpecification<AchFileEntity>(Session)
                .CheckProperty(c => c.FileIdModifier, "A")
                .CheckProperty(c => c.FileStatus, AchFileStatus.Created).CheckProperty(c => c.Locked, false)
                .CheckProperty(c => c.Name, new StringGenerator(16, 16).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();
        }
Exemple #32
0
        public void Should_accept_classes_with_protected_parameterless_constructor()
        {
            var _spec = new PersistenceSpecification <ProtectedConstructorClass>(sessionSource);

            _spec.VerifyTheMappings();
        }
        public void Setup()
        {
            var firstKitten = new Kitten { Id = 1, Name = "Kitten" };
            _cat = new Cat
            {
                Id = 100,
                Name = "Cat",
                FirstKitten = firstKitten,
                Picture = new Bitmap(5, 5),
                AllKittens = new List<Kitten>
                {
                    firstKitten,
                    new Kitten {Id = 2, Name = "Kitten2"},
                }
            };

            firstKitten = new Kitten { Id = 1, Name = "IdenticalKitten" };
            _identicalCat = new Cat
            {
                Id = 100,
                Name = "IdenticalCat",
                FirstKitten = firstKitten,
                Picture = new Bitmap(5, 5),
                AllKittens = new List<Kitten>
                {
                    firstKitten,
                    new Kitten {Id = 2, Name = "IdenticalKitten2"},
                }
            };

            _transaction = MockRepository.GenerateStub<ITransaction>();

            _session = MockRepository.GenerateStub<ISession>();
            _session.Stub(s => s.BeginTransaction()).Return(_transaction);
            _session.Stub(s => s.Get<Cat>(null)).IgnoreArguments().Return(_identicalCat);
            _session.Stub(s => s.GetIdentifier(_cat)).Return(_cat.Id);

            _sessionSource = MockRepository.GenerateStub<ISessionSource>();
            _sessionSource.Stub(ss => ss.CreateSession()).Return(_session);

            _spec = new PersistenceSpecification<Cat>(_sessionSource, new TestComparer());
        }
        public void AchFileTransactionSpecification()
        {
            var partner = new PersistenceSpecification<PartnerEntity>(Session)
               .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
           .VerifyTheMappings();

            new PersistenceSpecification<PartnerDetailEntity>(Session)
                .CheckProperty(c => c.CompanyIdentification, new StringGenerator(10, 10).GetRandomValue())
                .CheckProperty(c => c.CompanyName, new StringGenerator(5, 16).GetRandomValue())
                .CheckProperty(c => c.DfiIdentification, new StringGenerator(8, 8).GetRandomValue())
                .CheckProperty(c => c.Destination, new StringGenerator(5, 23).GetRandomValue())
                .CheckProperty(c => c.DiscretionaryData, new StringGenerator(5, 20).GetRandomValue())
                .CheckProperty(c => c.ImmediateDestination, new StringGenerator(5, 10).GetRandomValue())
                .CheckProperty(c => c.OriginOrCompanyName, new StringGenerator(5, 23).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();

            var transaction = new PersistenceSpecification<AchTransactionEntity>(Session)
                .CheckProperty(c => c.IndividualIdNumber, new StringGenerator(15, 15).GetRandomValue())
                .CheckProperty(c => c.ReceiverName, new StringGenerator(22, 22).GetRandomValue())
                .CheckProperty(c => c.Amount, (decimal)123.45)
                .CheckProperty(c => c.CallbackUrl, new StringGenerator(20, 255).GetRandomValue())
                .CheckProperty(c => c.DfiAccountId, new StringGenerator(17, 17).GetRandomValue())
                .CheckProperty(c => c.EntryClassCode, new StringGenerator(3, 3).GetRandomValue())
                .CheckProperty(c => c.EntryDate, DateTime.Now)
                .CheckProperty(c => c.EntryDescription, new StringGenerator(5, 10).GetRandomValue())
                .CheckProperty(c => c.PaymentRelatedInfo, new StringGenerator(4, 84).GetRandomValue())
                .CheckProperty(c => c.ServiceClassCode, new StringGenerator(3, 3).GetRandomValue())
                .CheckProperty(c => c.TransactionCode, new StringGenerator(2, 2).GetRandomValue())
                .CheckProperty(c => c.TransactionStatus, AchTransactionStatus.Received)
                .CheckProperty(c => c.TransitRoutingNumber, new StringGenerator(9, 9).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();

            var file = new PersistenceSpecification<AchFileEntity>(Session)
                .CheckProperty(c => c.FileIdModifier, "A")
                .CheckProperty(c => c.FileStatus, AchFileStatus.Uploaded)
                .CheckProperty(c => c.Locked, false)
                .CheckProperty(c => c.Name, new StringGenerator(16, 16).GetRandomValue())
                .CheckEntity(c => c.Partner, partner)
            .VerifyTheMappings();

            file.Transactions.Add(transaction);

            Session.Flush();
            Session.Clear();

            file = Session.Load<AchFileEntity>(file.Id);
            transaction = Session.Load<AchTransactionEntity>(transaction.Id);

            Assert.That(file.Transactions, Is.Not.Null);
            Assert.AreEqual(file.Transactions[0], transaction);
        }
 public void Should_accept_classes_with_public_parameterless_constructor()
 {
     var _spec = new PersistenceSpecification<PublicConstructorClass>(sessionSource);
     _spec.VerifyTheMappings();
 }
        public void PartnerDetailsSpecification()
        {
            var partner = new PersistenceSpecification<PartnerEntity>(Session)
                .CheckProperty(c => c.Name, ShortStringGenerator.GetRandomValue())
            .VerifyTheMappings();

            new PersistenceSpecification<PartnerDetailEntity>(Session)
                .CheckProperty(c => c.CompanyIdentification, new StringGenerator(10, 10).GetRandomValue())
                .CheckProperty(c => c.CompanyName, new StringGenerator(5, 16).GetRandomValue())
                .CheckProperty(c => c.DfiIdentification, new StringGenerator(8, 8).GetRandomValue())
                .CheckProperty(c => c.Destination, new StringGenerator(5, 23).GetRandomValue())
                .CheckProperty(c => c.DiscretionaryData, new StringGenerator(5, 20).GetRandomValue())
                .CheckProperty(c => c.ImmediateDestination, new StringGenerator(5, 10).GetRandomValue())
                .CheckProperty(c => c.OriginOrCompanyName, new StringGenerator(5, 23).GetRandomValue())
                .CheckEntity(c => c.Partner, partner).VerifyTheMappings();

            Session.Evict(partner);

            partner = Session.Load<PartnerEntity>(partner.Id);

            Assert.That(partner.Details, Is.Not.Null);
        }
Exemple #37
0
 public void build_accessor_for_an_enumerable()
 {
     PersistenceSpecification <PersistenceCheckTarget> .BuildCheck(x => x.Names)
     .ShouldBeOfType <EnumerablePersistenceCheck <string> >()
     .Accessor.Name.ShouldEqual("Names");
 }
Exemple #38
0
        public void Should_accept_instances_regardless_of_constructor()
        {
            var _spec = new PersistenceSpecification <NoParameterlessConstructorClass>(sessionSource);

            _spec.VerifyTheMappings(new NoParameterlessConstructorClass(123));
        }
Exemple #39
0
 public void build_accessor_for_a_non_enumerable()
 {
     PersistenceSpecification <PersistenceCheckTarget> .BuildCheck(x => x.Number)
     .ShouldBeOfType <AccessorPersistenceCheck>()
     .Accessor.Name.ShouldEqual("Number");
 }
        public void Setup()
        {
            var firstKitten = new Kitten { Id = 1, Name = "Kitten" };
            cat = new Cat
            {
                Id = 100,
                Name = "Cat",
                FirstKitten = firstKitten,
                Picture = new Bitmap(5, 5),
                AllKittens = new List<Kitten>
                {
                    firstKitten,
                    new Kitten {Id = 2, Name = "Kitten2"},
                }
            };

            firstKitten = new Kitten { Id = 1, Name = "IdenticalKitten" };
            identicalCat = new Cat
            {
                Id = 100,
                Name = "IdenticalCat",
                FirstKitten = firstKitten,
                Picture = new Bitmap(5, 5),
                AllKittens = new List<Kitten>
                {
                    firstKitten,
                    new Kitten {Id = 2, Name = "IdenticalKitten2"},
                }
            };

            transaction = A.Fake<ITransaction>();

            session = A.Fake<ISession>();
            A.CallTo(() => session.BeginTransaction()).Returns(transaction);
            A.CallTo(() => session.Get<Cat>(null)).WithAnyArguments().Returns(identicalCat);
            A.CallTo(() => session.GetIdentifier(cat)).Returns(cat.Id);

            sessionSource = A.Fake<ISessionSource>();
            A.CallTo(() => sessionSource.CreateSession()).Returns(session);

            spec = new PersistenceSpecification<Cat>(sessionSource, new TestComparer());
        }