コード例 #1
0
        public async Task GetAllCommandGetsAllFromUmbracoApi()
        {
            var service = Substitute.For <IContentTypeService>();

            service.GetAllContentTypes().Returns(_ => Enumerable.Empty <IContentType>());

            var deliverable = new ContentTypeDeliverable(
                null,
                Substitute.ForPartsOf <TextWriter>(),
                service,
                null,
                null,
                null,
                null
                );

            await deliverable.Run("", new[] { "get-all" });

            service.Received().GetAllContentTypes();
        }
コード例 #2
0
        public async Task GetCommandWithAliasReturnsItemFromUmbracoApi()
        {
            var service = Substitute.For <IContentTypeService>();

            service.GetContentType(Arg.Any <string>()).Returns(Substitute.For <IContentType>());

            var deliverable = new ContentTypeDeliverable(
                null,
                Substitute.For <TextWriter>(),
                service,
                null,
                null,
                null,
                null
                );

            await deliverable.Run("", new[] { "get", "alias" });

            service.Received().GetContentType(Arg.Any <string>());
        }
コード例 #3
0
        public async Task RemoveCommandWillCallRemoveMethod()
        {
            var service = Substitute.For <IContentTypeService>();

            service.GetContentType(Arg.Any <string>()).Returns(Substitute.For <IContentType>());
            service.Delete(Arg.Any <IContentType>());

            var deliverable = new ContentTypeDeliverable(
                null,
                Substitute.For <TextWriter>(),
                service,
                null,
                null,
                null,
                null
                );

            await deliverable.Run("", new[] { "remove", "alias" });

            service.Received().Delete(Arg.Any <IContentType>());
        }
コード例 #4
0
        public async Task RemovePropertyCommandWillRemoveAndSaveContentType()
        {
            var service = Substitute.For <IContentTypeService>();
            var ct      = Substitute.For <IContentType>();

            service.GetContentType(Arg.Any <string>()).Returns(ct);
            service.Save(Arg.Any <IContentType>());

            var deliverable = new ContentTypeDeliverable(
                null,
                Substitute.For <TextWriter>(),
                service,
                null,
                null,
                null,
                null
                );

            await deliverable.Run("", new[] { "remove-property", "alias", "property-alias" });

            ct.Received(1).RemovePropertyType(Arg.Any <string>());
            service.Received(1).Save(Arg.Is(ct));
        }