示例#1
0
        public void Process_DataItemIsComment_AddsCommentAndEntry()
        {
            // arrange
            var entryTemplateId   = ID.NewID;
            var commentTemplateId = ID.NewID;

            var(sut, dataItemMock, entryManager) = CreateResolveItems(commentTemplateId, entryTemplateId, commentTemplateId);
            var entryItem = ItemFactory.CreateItem(templateId: entryTemplateId);

            dataItemMock.Setup(x => x.Parent).Returns(entryItem.Object);

            var commentUri = new ItemUri(dataItemMock.Object);

            dataItemMock.Setup(x => x.Uri).Returns(commentUri);

            entryManager.Setup(x => x.GetBlogEntryItemByCommentUri(commentUri)).Returns(entryItem.Object);

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            sut.Process(args);

            // assert
            Assert.That(args.CommentItem.ID, Is.EqualTo(dataItemMock.Object.ID));
            Assert.That(args.EntryItem.ID, Is.EqualTo(entryItem.Object.ID));
        }
示例#2
0
        public void Process_ItemsAlreadySet_DoesNotChangeItemProperties()
        {
            // arrange
            var entryTemplateId   = ID.NewID;
            var commentTemplateId = ID.NewID;

            var(sut, dataItemMock, entryManager) = CreateResolveItems(commentTemplateId, entryTemplateId, commentTemplateId);
            var entryItem = ItemFactory.CreateItem(templateId: entryTemplateId);

            dataItemMock.Setup(x => x.Parent).Returns(entryItem.Object);

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            var existingEntryItem = ItemFactory.CreateItem(templateId: entryTemplateId).Object;

            args.EntryItem = existingEntryItem;

            var existingCommentItem = ItemFactory.CreateItem(templateId: commentTemplateId).Object;

            args.CommentItem = existingCommentItem;

            // act
            sut.Process(args);

            // assert
            Assert.That(args.CommentItem.ID, Is.EqualTo(existingCommentItem.ID));
            Assert.That(args.EntryItem.ID, Is.EqualTo(existingEntryItem.ID));
        }
        public void Ctor_WhenCalled_SetsProperties()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();

            // act
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // assert
            Assert.That(sut.WorkflowPipelineArgs, Is.SameAs(workflowPipelineArgs));
        }
        public void GetModelByKey_ObjectNotPresent_ReturnsNull()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            var result = sut.GetModel("key");

            // assert
            Assert.IsNull(result);
        }
        public void GetModel_NothingSet_ReturnsEmptyDictionary()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            var result = sut.GetModel();

            // assert
            Assert.That(result, Is.Empty);
        }
        public void AddModel_KeyIsInvalid_ThrowsException(string key)
        {
            // arrange
            var    workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var    sut       = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            Action sutAction = () => sut.AddModel(key, "value");

            // act, assert
            var ex = Assert.Throws <ArgumentException>(new TestDelegate(sutAction));

            Assert.That(ex.ParamName, Is.EqualTo("key"));
        }
        public void ModelContains_KeyIsInvalid_ReturnsFalse(string key)
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            var result = sut.ModelContains(key);

            // assert
            Assert.That(result, Is.False);
        }
        public void ModelContains_ObjectNotPresent_ReturnsFalse()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            var result = sut.ModelContains("other");

            // assert
            Assert.That(result, Is.False);
        }
        public void GetModelByKey_KeyIsInvalid_ReturnsNull(string key)
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            var result = sut.GetModel(key);

            // assert
            Assert.IsNull(result);
        }
示例#10
0
        public void Process_DataItemNotEntryOrComment_ItemPropertiesRemainNull()
        {
            // arrange
            var(sut, dataItemMock, entryManager) = CreateResolveItems(ID.NewID, ID.NewID, ID.NewID);
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            sut.Process(args);

            // assert
            Assert.That(args.EntryItem, Is.Null);
            Assert.That(args.CommentItem, Is.Null);
        }
        public void GetModelByKey_StringObjectIsPresent_ReturnsObject()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            sut.AddModel("key", "value");

            // act
            var result = sut.GetModel("key");

            // assert
            Assert.That(result, Is.EqualTo("value"));
        }
        public void RemoveModel_KeyIsInvalid_ReturnsFalse(string key)
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            sut.AddModel("key", "value");

            // act
            var result = sut.RemoveModel(key);

            // assert
            Assert.That(result, Is.False);
        }
        public void RemoveModel_ObjectIsPresent_ReturnsTrue()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            sut.AddModel("key", "value");

            // act
            var result = sut.RemoveModel("key");

            // assert
            Assert.That(result, Is.True);
        }
示例#14
0
        public void Process_DataItemIsEntry_AddsEntry()
        {
            // arrange
            var entryTemplateId = ID.NewID;

            var(sut, dataItemMock, entryManager) = CreateResolveItems(entryTemplateId, entryTemplateId, ID.NewID);
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            sut.Process(args);

            // assert
            Assert.That(args.EntryItem.ID, Is.EqualTo(dataItemMock.Object.ID));
        }
        public void Process_WhenCalled_AddsCurrentTimestamp()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddCurrentTimestamp();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddCurrentTimestamp.ModelKey);

            Assert.That(value, Is.EqualTo(DateTime.Now).Within(TimeSpan.FromSeconds(1)));
        }
示例#16
0
        public void Process_WhenCalled_AddsDataItem()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddDataItem();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddDataItem.ModelKey);

            Assert.That(value, Is.SameAs(workflowPipelineArgs.DataItem));
        }
        public void GetModelByKey_ObjectIsPresent_ReturnsObject()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut   = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var value = new Tuple <string, int, DateTime>("item1", 42, DateTime.Today);

            sut.AddModel("key", value);

            // act
            var result = sut.GetModel("key");

            // assert
            Assert.That(result, Is.EqualTo(value));
        }
        public void RemoveModel_ObjectIsPresent_RemovesObject()
        {
            // arrange
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var sut = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            sut.AddModel("key", "value");

            // act
            sut.RemoveModel("key");
            var exists = sut.ModelContains("key");

            // assert
            Assert.That(exists, Is.False);
        }
示例#19
0
        public void Process_NoBlogs_DoesNotAddToModel()
        {
            // arrange
            var blogManager          = Mock.Of <IBlogManager>();
            var sut                  = new AddBlog(blogManager);
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var args                 = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            sut.Process(args);

            // assert
            var blogExists = args.ModelContains(AddBlog.ModelKey);

            Assert.That(blogExists, Is.False);
        }
示例#20
0
        public void Process_WhenCalled_AddsUser()
        {
            // arrange
            var user = User.FromName("sitecore\\user", false);
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddUser(user);

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddUser.ModelKey);

            Assert.That(value, Is.EqualTo(user));
        }
示例#21
0
        public void Process_CommentItemIsNull_AddsNothing()
        {
            // arrange
            var dataItemMock         = ItemFactory.CreateItem();
            var sut                  = new AddComment();
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args                 = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            // act
            sut.Process(args);

            // assert
            var commentExists = args.ModelContains(AddComment.ModelKey);

            Assert.That(commentExists, Is.False);
        }
        public void Process_EntryItemIsNotNull_AddsEntry()
        {
            // arrange
            var(sut, dataItem) = CreateAddEntryModels();
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItem);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            args.EntryItem = new EntryItem(dataItem);

            // act
            sut.Process(args);

            // assert
            var entry = args.GetModel(AddEntryModels.EntryModelKey);

            Assert.That(((EntryItem)entry).ID, Is.EqualTo(dataItem.ID));
        }
        public void Process_EntryItemIsNotNull_AddsUpdatedByUser()
        {
            // arrange
            var(sut, dataItem) = CreateAddEntryModels();
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItem);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            args.EntryItem = new EntryItem(dataItem);

            // act
            sut.Process(args);

            // assert
            var updatedBy = args.GetModel(AddEntryModels.UpdatedByModelKey);

            Assert.That(((UserProfile)updatedBy).Name, Is.EqualTo(UserName));
        }
示例#24
0
        public void Process_CommentItemIsNotNull_AddsComment()
        {
            // arrange
            var dataItemMock         = ItemFactory.CreateItem();
            var sut                  = new AddComment();
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args                 = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);

            args.CommentItem = new CommentItem(dataItemMock.Object);

            // act
            sut.Process(args);

            // assert
            var comment = args.GetModel(AddComment.ModelKey);

            Assert.That(((CommentItem)comment).ID, Is.EqualTo(dataItemMock.Object.ID));
        }
        public void Process_ItemHasWorkflowHistory_AddsWorkflowHistory()
        {
            // arrange
            var dataItemMock   = ItemFactory.CreateItem();
            var workflowEvents = AddItemHistory(dataItemMock, new[] { ID.NewID, ID.NewID });

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddWorkflowHistory();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddWorkflowHistory.ModelKey);

            Assert.That((WorkflowEvent[])value, Is.EquivalentTo(workflowEvents));
        }
示例#26
0
        public void Process_WhenCalled_AddsSite()
        {
            // arrange
            var siteInfo = new SiteInfo(new StringDictionary());
            var site     = new SiteContext(siteInfo);

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddSite(site);

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddSite.ModelKey);

            Assert.That(value, Is.EqualTo(site));
        }
示例#27
0
        public void Process_WhenCalled_AddsActionDefinitionItem()
        {
            // arrange
            var actionItem           = ItemFactory.CreateItem();
            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();

            workflowPipelineArgs.ProcessorItem = actionItem.Object;

            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddActionItem();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddActionItem.ModelKey);

            Assert.That(((ProcessorItem)value).ID, Is.EqualTo(actionItem.Object.ID));
        }
        public void Process_ItemHasNoWorkflowHistory_HistoryObjectIsEmpty()
        {
            // arrange
            var dataItemMock = ItemFactory.CreateItem();

            AddItemHistory(dataItemMock, new ID[0]);

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddWorkflowHistory();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddWorkflowHistory.ModelKey);

            Assert.That((WorkflowEvent[])value, Is.Empty);
        }
        public void Process_ItemHasNoWorkflow_HistoryObjectIsEmpty()
        {
            // arrange
            var dataItemMock = ItemFactory.CreateItem();
            var itemState    = new Mock <ItemState>(dataItemMock.Object);

            dataItemMock.Setup(x => x.State).Returns(itemState.Object);

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs(dataItemMock.Object);
            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddWorkflowHistory();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddWorkflowHistory.ModelKey);

            Assert.That((WorkflowEvent[])value, Is.Empty);
        }
        public void Process_NextStatePresent_AddsState()
        {
            // arrange
            var actionItem = CreateWorkflowItems();

            var workflowPipelineArgs = WorkflowPipelineArgsFactory.CreateWorkflowPipelineArgs();

            workflowPipelineArgs.ProcessorItem = new ProcessorItem(actionItem);

            var args = new PopulateScribanMailActionModelArgs(workflowPipelineArgs);
            var sut  = new AddNextWorkflowState();

            // act
            sut.Process(args);

            // assert
            var value = args.GetModel(AddNextWorkflowState.ModelKey);

            Assert.That(value, Is.EqualTo("next state"));
        }