protected override void TestMappings(PersistenceSpecification <SongsAlbum> specification)
        {
            Assertion.NotNull(specification);

            base.TestMappings(specification);
            specification.CheckProperty(mapping => mapping.Image, "image");
            specification.CheckProperty(mapping => mapping.PublishedOn, DateTime.UtcNow);
        }
        protected override void TestMappings(PersistenceSpecification <TextTranslation> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Language, "ru");
            specification.CheckProperty(mapping => mapping.Name, "name");
            specification.CheckProperty(mapping => mapping.Text, "text");
            specification.CheckProperty(mapping => mapping.Translator, "translator");
        }
        protected override void TestMappings(PersistenceSpecification <Setting> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Name, "name");
            specification.CheckProperty(mapping => mapping.Value, "value");
        }
        protected override void TestMappings(PersistenceSpecification <ENTITY> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Description, "description");
            specification.CheckProperty(mapping => mapping.Language, "ru");
            specification.CheckProperty(mapping => mapping.Name, "name");
        }
コード例 #5
0
        protected override void TestMappings(PersistenceSpecification <Country> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Image, "image");
            specification.CheckProperty(mapping => mapping.IsoCode, "ru");
            specification.CheckProperty(mapping => mapping.Name, "name");
        }
コード例 #6
0
        protected override void TestMappings(PersistenceSpecification <Notification> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Language, "ru");
            specification.CheckProperty(mapping => mapping.Text, "text");
            specification.CheckProperty(mapping => mapping.Type, 1);
        }
        protected override void TestMappings(PersistenceSpecification <Playcast> specification)
        {
            Assertion.NotNull(specification);

            var category = new PlaycastsCategory("category.name");

            specification.TransactionalSave(category);

            base.TestMappings(specification);
            specification.CheckProperty(mapping => mapping.Audio, "audio");
            specification.CheckReference(mapping => mapping.Category, category);
            specification.CheckProperty(mapping => mapping.Image, "image");
        }
        protected override void TestMappings(PersistenceSpecification <Article> specification)
        {
            Assertion.NotNull(specification);

            var category = new ArticlesCategory("category.name");

            specification.TransactionalSave(category);

            base.TestMappings(specification);
            specification.CheckProperty(mapping => mapping.Annotation, "annotation");
            specification.CheckReference(mapping => mapping.Category, category);
            specification.CheckProperty(mapping => mapping.Image, "image");
        }
コード例 #9
0
        protected override void TestMappings(PersistenceSpecification <Download> specification)
        {
            Assertion.NotNull(specification);

            var category = new DownloadsCategory("category.name");

            specification.TransactionalSave(category);

            base.TestMappings(specification);
            specification.CheckReference(mapping => mapping.Category, category);
            specification.CheckProperty(mapping => mapping.Downloads, (long)1);
            specification.CheckProperty(mapping => mapping.Url, "url");
        }
        protected override void TestMappings(PersistenceSpecification <City> specification)
        {
            Assertion.NotNull(specification);

            var country = new Country("country.name", "ru");

            specification.TransactionalSave(country);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckReference(mapping => mapping.Country, country);
            specification.CheckProperty(mapping => mapping.Name, "name");
            specification.CheckProperty(mapping => mapping.Region, "region");
        }
コード例 #11
0
        protected override void TestMappings(PersistenceSpecification <Announcement> specification)
        {
            Assertion.NotNull(specification);

            var category = new AnnouncementsCategory("category.name");

            specification.TransactionalSave(category);

            base.TestMappings(specification);
            specification.CheckReference(mapping => mapping.Category, category);
            specification.CheckProperty(mapping => mapping.Currency, "rub");
            specification.CheckProperty(mapping => mapping.Image, "image");
            specification.CheckProperty(mapping => mapping.Price, (decimal)1);
        }
        protected override void TestMappings(PersistenceSpecification <Audio> specification)
        {
            Assertion.NotNull(specification);

            var category = new AudiosCategory("category.name");

            specification.TransactionalSave(category);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Bitrate, (short)16);
            specification.CheckReference(mapping => mapping.Category, category);
            specification.CheckProperty(mapping => mapping.Duration, (long)10);
            specification.CheckProperty(mapping => mapping.File, "file");
        }
        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();
        }
コード例 #14
0
        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();
        }
コード例 #15
0
        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();
        }
        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();
        }
        protected override void TestMappings(PersistenceSpecification <Art> specification)
        {
            Assertion.NotNull(specification);

            //var album = new ArtsAlbum("album.name");
            var person = new Person("person.nameFirst", "person.nameLast");

            //specification.TransactionalSave(album);
            specification.TransactionalSave(person);

            base.TestMappings(specification);
            //specification.CheckReference(mapping => mapping.Album, album);
            specification.CheckProperty(mapping => mapping.Image, "image");
            specification.CheckProperty(mapping => mapping.Material, "material");
            specification.CheckReference(mapping => mapping.Person, person);
            specification.CheckProperty(mapping => mapping.Place, "place");
        }
コード例 #18
0
        public static PersistenceSpecification <T> CheckProperty <T>(
            this PersistenceSpecification <T> spec, Expression <Func <T, object> > expression, DateTime propertyValue)
        {
            var ticks    = propertyValue.Ticks - (propertyValue.Ticks % TimeSpan.TicksPerSecond);
            var newValue = new DateTime(ticks, propertyValue.Kind);

            return(spec.CheckProperty(expression, (object)newValue));
        }
コード例 #19
0
        protected override void TestMappings(PersistenceSpecification <Song> specification)
        {
            Assertion.NotNull(specification);

            //var album = new SongsAlbum("ru", "album.name");
            //specification.TransactionalSave(album);

            base.TestMappings(specification);
            //specification.CheckReference(mapping => mapping.Album, album);
            specification.CheckProperty(mapping => mapping.Audio, "audio");
        }
        protected override void TestMappings(PersistenceSpecification <Profile> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Email, "email");
            specification.CheckProperty(mapping => mapping.Name, "name");
            specification.CheckProperty(mapping => mapping.Photo, "photo");
            specification.CheckProperty(mapping => mapping.Type, "type");
            specification.CheckProperty(mapping => mapping.Url, "url");
            specification.CheckProperty(mapping => mapping.Username, "username");
        }
コード例 #21
0
        protected override void TestMappings(PersistenceSpecification <Subscription> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Active, true);
            specification.CheckProperty(mapping => mapping.CreatedAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.Email, "email");
            specification.CheckProperty(mapping => mapping.ExpiredAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.UpdatedAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.Token, "token");
        }
        protected override void TestMappings(PersistenceSpecification <Comment> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.CreatedAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.UpdatedAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.Name, "name");
            specification.CheckProperty(mapping => mapping.Text, "text");
        }
        protected override void TestMappings(PersistenceSpecification <ENTITY> specification)
        {
            Assertion.NotNull(specification);

            var comment = new Comment("comment.name", "comment.text");

            specification.TransactionalSave(comment);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckInverseBag(mapping => mapping.Comments, new[] { comment });
            specification.CheckProperty(mapping => mapping.CreatedAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.Language, "ru");
            specification.CheckProperty(mapping => mapping.UpdatedAt, DateTime.UtcNow);
            specification.CheckProperty(mapping => mapping.Name, "name");
            specification.CheckInverseBag(mapping => mapping.Tags, new[] { "first", "second" });
            specification.CheckProperty(mapping => mapping.Text, "text");
        }
        protected override void TestMappings(PersistenceSpecification <Location> specification)
        {
            Assertion.NotNull(specification);

            var country = new Country("city.country.name", "ru");
            var city    = new City("city.name", country);

            specification.TransactionalSave(country);
            specification.TransactionalSave(city);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.Address, "address");
            specification.CheckReference(mapping => mapping.City, city);
            specification.CheckProperty(mapping => mapping.Latitude, (decimal)90);
            specification.CheckProperty(mapping => mapping.Longitude, (decimal)180);
            specification.CheckProperty(mapping => mapping.PostalCode, "postalCode");
        }
        protected override void TestMappings(PersistenceSpecification <Person> specification)
        {
            Assertion.NotNull(specification);

            specification.CheckProperty(mapping => mapping.Id, (long)1);
            specification.CheckProperty(mapping => mapping.Version, (long)1);
            specification.CheckProperty(mapping => mapping.BirthDay, (byte)1);
            specification.CheckProperty(mapping => mapping.BirthMonth, (byte)12);
            specification.CheckProperty(mapping => mapping.BirthYear, (short)2000);
            specification.CheckProperty(mapping => mapping.DeathDay, (byte)31);
            specification.CheckProperty(mapping => mapping.DeathMonth, (byte)2);
            specification.CheckProperty(mapping => mapping.DeathYear, (short)2100);
            specification.CheckProperty(mapping => mapping.Description, "description");
            specification.CheckProperty(mapping => mapping.Image, "image");
            specification.CheckProperty(mapping => mapping.NameFirst, "nameFirst");
            specification.CheckProperty(mapping => mapping.NameLast, "nameLast");
            specification.CheckProperty(mapping => mapping.NameMiddle, "nameMiddle");
        }
コード例 #26
0
 public void Comparing_two_properties_should_use_the_specified_IEqualityComparer()
 {
     spec.CheckProperty(x => x.FirstKitten, cat.FirstKitten).VerifyTheMappings();
 }
コード例 #27
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()));
 }