コード例 #1
0
        public async Task GetList_WithoutItemType_PassesExpectedQuery()
        {
            GetSuppliersByNameQuery actualQuery = null;

            var mockMediator = new Mock <IMediator>();

            mockMediator
            .Setup(m => m.Send(It.IsNotNull <IRequest <IEnumerable <ISupplier> > >(), It.IsAny <CancellationToken>()))
            .Callback <IRequest <IEnumerable <ISupplier> >, CancellationToken>((q, _) => actualQuery = (GetSuppliersByNameQuery)q)
            .ReturnsAsync(Array.Empty <ISupplier>());

            const string          expectedName            = "Supplier Name";
            const PublishedStatus expectedPublishedStatus = PublishedStatus.Draft;

            var controller  = new SuppliersController(mockMediator.Object);
            var searchQuery = new SupplierSearchQueryModel
            {
                Name = expectedName,
                SolutionPublicationStatus = expectedPublishedStatus,
            };

            await controller.GetList(searchQuery);

            var expectedQuery = new GetSuppliersByNameQuery(expectedName, expectedPublishedStatus, CatalogueItemType.Solution);

            actualQuery.Should().BeEquivalentTo(expectedQuery);
        }
コード例 #2
0
        protected override GutterIconDescriptor GetIconDescriptor(Item item)
        {
            PublishedStatus publishedStatus = CheckPublishedStatus(item);

            if (publishedStatus != PublishedStatus.Published)
            {
                GutterIconDescriptor gutterIconDescriptor = new GutterIconDescriptor();

                if (publishedStatus == PublishedStatus.NeverPublished)
                {
                    gutterIconDescriptor.Icon    = "Applications/32x32/bullet_ball_red.png";
                    gutterIconDescriptor.Tooltip = "Item was never published";
                }
                else
                {
                    gutterIconDescriptor.Icon    = "Applications/32x32/bullet_ball_yellow.png";
                    gutterIconDescriptor.Tooltip = "Item is published but modified";
                }

                gutterIconDescriptor.Click = string.Format("item:load(id={0})", item.ID);
                return(gutterIconDescriptor);
            }

            return(null);
        }
        private static async Task InsertSupplier(PublishedStatus solutionPublicationStatus = PublishedStatus.Published)
        {
            await SupplierEntityBuilder.Create()
            .WithId(SupplierId)
            .WithName(SupplierName)
            .WithSummary(Description)
            .WithSupplierUrl(Link)
            .WithAddress(SupplierAddress)
            .Build()
            .InsertAsync();

            await SupplierContactEntityBuilder.Create()
            .WithId(Guid.NewGuid())
            .WithSupplierId(SupplierId)
            .WithFirstName(SupplierContactFirstName)
            .WithLastName(SupplierContactLastName)
            .WithEmail(SupplierContactEmail)
            .WithPhoneNumber(SupplierContactPhoneNumber)
            .Build()
            .InsertAsync();

            await CatalogueItemEntityBuilder
            .Create()
            .WithCatalogueItemId(SolutionId)
            .WithName(SolutionId)
            .WithSupplierId(SupplierId)
            .WithPublishedStatusId((int)solutionPublicationStatus)
            .Build()
            .InsertAsync();

            await SolutionEntityBuilder.Create()
            .WithId(SolutionId)
            .Build()
            .InsertAsync();
        }
コード例 #4
0
 void Application_DocumentChange()
 {
     //Reassign values to the document and wiki page states.
     lastActiveDocument         = ActiveDocumentInstance;
     lastActiveDocumentFullName = ActiveDocumentFullName;
     activeDocumentContent      = ActiveDocumentContentRange;
     //if current document is a wiki page.
     if (EditedPages.ContainsKey(lastActiveDocumentFullName))
     {
         currentPageFullName  = EditedPages[lastActiveDocumentFullName];
         CurrentPagePublished = false;
         if (PublishedStatus.ContainsKey(currentPageFullName))
         {
             if (PublishedStatus[currentPageFullName])
             {
                 CurrentPagePublished = true;
             }
         }
     }
     else
     {
         currentPageFullName  = null;
         CurrentPagePublished = false;
     }
 }
コード例 #5
0
ファイル: PostProvider.cs プロジェクト: qvacuba/Blogifier
        public async Task <List <Post> > GetPosts(PublishedStatus filter, PostType postType)
        {
            switch (filter)
            {
            case PublishedStatus.Published:
                return(await _db.Posts.AsNoTracking().Where(p => p.PostType == postType).Where(p => p.Published > DateTime.MinValue).OrderByDescending(p => p.Published).ToListAsync());

            case PublishedStatus.Drafts:
                return(await _db.Posts.AsNoTracking().Where(p => p.PostType == postType).Where(p => p.Published == DateTime.MinValue).OrderByDescending(p => p.Id).ToListAsync());

            case PublishedStatus.Featured:
                return(await _db.Posts.AsNoTracking().Where(p => p.PostType == postType).Where(p => p.IsFeatured).OrderByDescending(p => p.Id).ToListAsync());

            default:
                return(await _db.Posts.AsNoTracking().Where(p => p.PostType == postType).OrderByDescending(p => p.Id).ToListAsync());
            }
        }
        public static async Task <CatalogueItemEntity> CreateCatalogueItemEntity(
            string catalogueItemId,
            string supplierId,
            CatalogueItemType catalogueItemType,
            PublishedStatus publishedStatus = PublishedStatus.Published)
        {
            var catalogueItem = CatalogueItemEntityBuilder
                                .Create()
                                .WithCatalogueItemId(catalogueItemId)
                                .WithSupplierId(supplierId)
                                .WithCatalogueItemTypeId((int)catalogueItemType)
                                .WithPublishedStatusId((int)publishedStatus)
                                .Build();

            await catalogueItem.InsertAsync();

            return(catalogueItem);
        }
 public async Task ByNameAsync_ReturnsExpectedValues()
 {
     const string            supplierName   = "Supplier";
     const PublishedStatus   solutionStatus = PublishedStatus.Published;
     const CatalogueItemType itemType       = CatalogueItemType.Solution;
コード例 #8
0
 public async Task ByNameAsync_ReturnsExpectedValues()
 {
     const string          supplierName   = "Supplier";
     const PublishedStatus solutionStatus = PublishedStatus.Published;
コード例 #9
0
 /// <summary>
 /// Initialises a new instance of the <see cref="Solution"/> class.
 /// </summary>
 public Solution()
 {
     SupplierStatus  = SupplierStatus.Draft;
     PublishedStatus = PublishedStatus.Draft;
 }
コード例 #10
0
 public async Task <ActionResult <List <Post> > > GetPosts(PublishedStatus filter, PostType postType)
 {
     return(await _postProvider.GetPosts(filter, postType));
 }
コード例 #11
0
 public void ChangePublishedStatus()
 {
     Status = Status == PublishedStatus.Live ? PublishedStatus.Draft : PublishedStatus.Live;
 }
コード例 #12
0
 public async Task Handle_ReturnsExpectedResults()
 {
     const string          supplier       = "Supplier";
     const PublishedStatus solutionStatus = PublishedStatus.Published;