コード例 #1
0
        public async Task GetDefault_NoDefault()
        {
            var internalId = Guid.NewGuid().ToString("N");
            var site       = new Site
            {
                Description = $"Site description {internalId}",
                InternalId  = internalId,
                Title       = $"Title {internalId}",
                IsDefault   = false
            };
            var repository = new SiteRepository(SessionFactory, new ContentServiceFactory(_contentFactory));
            await repository.Save(site).ConfigureAwait(false);

            var defaultSite = await repository.GetDefault().ConfigureAwait(false);

            Assert.IsNull(defaultSite);
        }
コード例 #2
0
        public async Task GetDefault_WithExistingDefault()
        {
            var internalId = Guid.NewGuid().ToString("N");
            var site       = new Site
            {
                Description = $"Site description {internalId}",
                InternalId  = internalId,
                Title       = $"Title {internalId}",
                IsDefault   = true
            };
            var repository = new SiteRepository(SessionFactory, new ContentServiceFactory(_contentFactory));
            await repository.Save(site).ConfigureAwait(false);

            var siteId      = site.Id;
            var defaultSite = await repository.GetDefault().ConfigureAwait(false);

            Assert.AreEqual(siteId, defaultSite.Id);
            Assert.IsTrue(defaultSite.IsDefault);
        }